| 1209 | } |
| 1210 | |
| 1211 | double nearestPowerOfTwoScale(const double value) { |
| 1212 | int exp_scale; |
| 1213 | // Decompose value into a normalized fraction and an integral power |
| 1214 | // of two. |
| 1215 | // |
| 1216 | // If arg is zero, returns zero and stores zero in *exp. Otherwise |
| 1217 | // (if arg is not zero), if no errors occur, returns the value x in |
| 1218 | // the range (-1;-0.5], [0.5; 1) and stores an integer value in *exp |
| 1219 | // such that x×2(*exp)=arg |
| 1220 | double check_x = std::frexp(value, &exp_scale); |
| 1221 | if (std::fabs(check_x) == 0.5) { |
| 1222 | check_x *= 2; |
| 1223 | exp_scale--; |
| 1224 | } |
| 1225 | const double check_value = check_x * std::pow(2, exp_scale); |
| 1226 | assert(check_value == value); |
| 1227 | exp_scale = -exp_scale; |
| 1228 | // Multiply a floating point value x(=1) by the number 2 raised to |
| 1229 | // the exp power |
| 1230 | double scale = std::ldexp(1, exp_scale); |
| 1231 | return scale; |
| 1232 | } |
| 1233 | |
| 1234 | void highsAssert(const bool assert_condition, const std::string& message) { |
| 1235 | if (assert_condition) return; |
no outgoing calls
no test coverage detected