Fix negative readings
We were making negative values 0. This fixes
the issue by converting using an int instead.
Tested: Tests pass
Change-Id: I389a90f52832f1a70b66fdddd8135c77011843a2
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/tests/test_sensorcommands.cpp b/tests/test_sensorcommands.cpp
index a0ca740..5513603 100644
--- a/tests/test_sensorcommands.cpp
+++ b/tests/test_sensorcommands.cpp
@@ -52,6 +52,12 @@
EXPECT_EQ(bExp, 0);
}
+ // check negative values
+ expected = 236; // 2s compliment -20
+ scaledVal = ipmi::scaleIPMIValueFromDouble(-20, mValue, rExp, bValue, bExp,
+ bSigned);
+ EXPECT_NEAR(scaledVal, expected, expected * 0.01);
+
// fan example
maxValue = 16000;
minValue = 0;