MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / scientific_exponent

Function scientific_exponent

external/include/fast_float/fast_float.h:2486–2502  ·  view source on GitHub ↗

calculate the exponent, in scientific notation, of the number. this algorithm is not even close to optimized, but it has no practical effect on performance: in order to have a faster algorithm, we'd need to slow down performance for faster algorithms, and this is still fast.

Source from the content-addressed store, hash-verified

2484// effect on performance: in order to have a faster algorithm, we'd need
2485// to slow down performance for faster algorithms, and this is still fast.
2486fastfloat_really_inline int32_t scientific_exponent(parsed_number_string& num) noexcept {
2487 uint64_t mantissa = num.mantissa;
2488 int32_t exponent = int32_t(num.exponent);
2489 while (mantissa >= 10000) {
2490 mantissa /= 10000;
2491 exponent += 4;
2492 }
2493 while (mantissa >= 100) {
2494 mantissa /= 100;
2495 exponent += 2;
2496 }
2497 while (mantissa >= 10) {
2498 mantissa /= 10;
2499 exponent += 1;
2500 }
2501 return exponent;
2502}
2503
2504// this converts a native floating-point number to an extended-precision float.
2505template <typename T>

Callers 1

digit_compFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected