Lines Matching +full:range +full:- +full:double
8 // http://www.apache.org/licenses/LICENSE-2.0
17 #include "dbus-sdr/sensorutils.hpp"
19 #include <phosphor-logging/lg2.hpp>
28 static bool baseInRange(double base) in baseInRange()
30 auto min10 = static_cast<double>(minInt10); in baseInRange()
31 auto max10 = static_cast<double>(maxInt10); in baseInRange()
37 // Ensures floating-point "base" is within bounds,
40 // the floating-point "base" will be as large as possible,
47 // Returns true if successful, modifies values in-place
48 static bool scaleFloatExp(double& base, int8_t& expShift) in scaleFloatExp()
50 // Comparing with zero should be OK, zero is special in floating-point in scaleFloatExp()
57 // As long as base value is within allowed range, expand precision in scaleFloatExp()
69 --expShift; in scaleFloatExp()
72 // As long as base value is *not* within range, shrink precision in scaleFloatExp()
73 // This will pull base value closer to zero, thus within range in scaleFloatExp()
87 // If the above loop was not able to pull it back within range, in scaleFloatExp()
100 // Also modify floating-point "dbase" at the same time,
101 // as both integer and floating-point base share the same expShift.
104 // Always successful, modifies values in-place
105 static void normalizeIntExp(int16_t& ibase, int8_t& expShift, double& dbase) in normalizeIntExp()
131 // The floating-point base must be kept in sync with the integer base, in normalizeIntExp()
132 // as both floating-point and integer share the same exponent. in normalizeIntExp()
142 …el.com/content/dam/www/public/us/en/documents/product-briefs/ipmi-second-gen-interface-spec-v2-rev…
151 bool getSensorAttributes(const double max, const double min, int16_t& mValue, in getSensorAttributes()
174 // y comes in from D-Bus (the actual sensor reading) in getSensorAttributes()
176 // If y is min, x should equal = 0 (or -128 if signed) in getSensorAttributes()
178 double fullRange = max - min; in getSensorAttributes()
179 double lowestX; in getSensorAttributes()
193 // TODO(): It would be worth experimenting with the range (-127,127), in getSensorAttributes()
194 // instead of the range (-128,127), because this in getSensorAttributes()
196 // Divide by 254 instead of 255, and change -128 to -127 elsewhere. in getSensorAttributes()
198 lowestX = -128.0; in getSensorAttributes()
206 // Step 1: Set y to (max - min), set x to 255, set B to 0, solve for M in getSensorAttributes()
208 // because total range is the same. in getSensorAttributes()
209 double dM = fullRange / 255.0; in getSensorAttributes()
215 "getSensorAttributes: Multiplier range exceeds scale (M={DM}, " in getSensorAttributes()
228 lg2::error("getSensorAttributes: Multiplier range below scale"); in getSensorAttributes()
233 // If negative, x will be -128 (the most negative possible byte), not 0 in getSensorAttributes()
237 // B = 10^(-rExp - bExp) (y - M 10^rExp x) in getSensorAttributes()
239 …rtC1LLNJQr1TX5KqAMCuATF8I0xfIdIIwnYDMIteKAggPxAIKJMEFkiACxfk5Zaka0ZUKtrYKGhq-CloKFZoK2goaTkCWhqGBg… in getSensorAttributes()
240 double dB = std::pow(10.0, ((-rExp) - bExp)) * in getSensorAttributes()
241 (min - ((dM * std::pow(10.0, rExp) * lowestX))); in getSensorAttributes()
247 "getSensorAttributes: Offset range exceeds scale (B={DB}, " in getSensorAttributes()
261 uint8_t scaleIPMIValueFromDouble(const double value, const int16_t mValue, in scaleIPMIValueFromDouble()
271 auto dM = static_cast<double>(mValue); in scaleIPMIValueFromDouble()
272 auto dB = static_cast<double>(bValue); in scaleIPMIValueFromDouble()
276 // x = (10^(-rExp) (y - B 10^(rExp + bExp)))/M and M 10^rExp!=0 in scaleIPMIValueFromDouble()
278 …rtC1LLNJQr1TX5KqAMCuATF8I0xfIdIIwnYDMIteKAggPxAIKJMEFkiACxfk5Zaka0ZUKtrYKGhq-CloKFZoK2goaTkCWhqGBg… in scaleIPMIValueFromDouble()
279 double dX = in scaleIPMIValueFromDouble()
280 (std::pow(10.0, -rExp) * (value - (dB * std::pow(10.0, rExp + bExp)))) / in scaleIPMIValueFromDouble()
289 // sometimes the resulting byte is slightly out of range. in scaleIPMIValueFromDouble()
290 // Still allow this, but clamp the values to range. in scaleIPMIValueFromDouble()
309 uint8_t getScaledIPMIValue(const double value, const double max, in getScaledIPMIValue()
310 const double min) in getScaledIPMIValue()