Sync sensorutils.hpp with the latest

sensorutils.hpp was updated to handle negative sensor values, so
sync with that and a rounding change.

Change-Id: Ib9faea5e6063367973b4611f0b9137d00b83859b
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
diff --git a/include/sensorutils.hpp b/include/sensorutils.hpp
index 8d3ed75..ce5d775 100644
--- a/include/sensorutils.hpp
+++ b/include/sensorutils.hpp
@@ -145,7 +145,7 @@
         bExp -= 1;
     }
 
-    mValue = static_cast<int16_t>(mDouble) & maxInt10;
+    mValue = static_cast<int16_t>(std::round(mDouble)) & maxInt10;
     bValue = static_cast<int16_t>(bDouble) & maxInt10;
 
     return true;
@@ -156,21 +156,26 @@
                              const int8_t rExp, const uint16_t bValue,
                              const int8_t bExp, const bool bSigned)
 {
-    uint32_t scaledValue =
+    int32_t scaledValue =
         (value - (bValue * std::pow(10, bExp) * std::pow(10, rExp))) /
         (mValue * std::pow(10, rExp));
 
-    if (scaledValue > std::numeric_limits<uint8_t>::max() ||
-        scaledValue < std::numeric_limits<uint8_t>::lowest())
-    {
-        throw std::out_of_range("Value out of range");
-    }
     if (bSigned)
     {
+        if (scaledValue > std::numeric_limits<int8_t>::max() ||
+            scaledValue < std::numeric_limits<int8_t>::lowest())
+        {
+            throw std::out_of_range("Value out of range");
+        }
         return static_cast<int8_t>(scaledValue);
     }
     else
     {
+        if (scaledValue > std::numeric_limits<uint8_t>::max() ||
+            scaledValue < std::numeric_limits<uint8_t>::lowest())
+        {
+            throw std::out_of_range("Value out of range");
+        }
         return static_cast<uint8_t>(scaledValue);
     }
 }