Changeset 1253 for cpp/common
- Timestamp:
- 06/22/23 03:27:28 (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/nonstd_math.h
r1053 r1253 38 38 std::string doubleToString(double x, int precision); 39 39 double round(const double x, const int precision); 40 static inline void clipNegativeZeroIfNeeded(double& value, const double range_low) 41 { 42 if (value == 0.0 && range_low == 0.0) // if we have range_low==0.0 and we get value==-0.0 (which is ==0.0) 43 value = 0.0; //turn -0.0 to 0.0 so that it does not look like exceeding the allowed range (even though -0.0==0.0). This code unnecessarily also "overwrites" value==0.0 with 0.0, but it is faster and simpler than additionally checking std::signbit(value) just to distinguish -0.0 from 0.0. 44 //these conditions are not intended for range_low==-0.0, as we assume nobody would define allowed ranges using -0.0. 45 } 40 46 41 47
Note: See TracChangeset
for help on using the changeset viewer.