Assuming a limited support of built-in hexadecimal floats (see C99, C++17) that is a fall-back implementation. Performance has been optimized WRT to heap activity, however the calculation part is not optimized.
| 495 | // Assuming a limited support of built-in hexadecimal floats (see C99, C++17) that is a fall-back implementation. |
| 496 | // Performance has been optimized WRT to heap activity, however the calculation part is not optimized. |
| 497 | static double floatHexToDoubleNumber(const std::string& str) |
| 498 | { |
| 499 | const std::size_t p = str.find_first_of("pP",3); |
| 500 | const double factor1 = myStod(str, str.cbegin() + 2, str.cbegin()+p, 16); |
| 501 | const bool suffix = (str.back() == 'f') || (str.back() == 'F') || (str.back() == 'l') || (str.back() == 'L'); |
| 502 | const double exponent = myStod(str, str.cbegin() + p + 1, suffix ? str.cend()-1:str.cend(), 10); |
| 503 | const double factor2 = std::pow(2, exponent); |
| 504 | return factor1 * factor2; |
| 505 | } |
| 506 | |
| 507 | double MathLib::toDoubleNumber(const Token * tok) |
| 508 | { |
no test coverage detected