multiply as if by 5 raised to a power.
| 2393 | |
| 2394 | // multiply as if by 5 raised to a power. |
| 2395 | FASTFLOAT_CONSTEXPR20 bool pow5(uint32_t exp) noexcept { |
| 2396 | // multiply by a power of 5 |
| 2397 | size_t large_length = sizeof(large_power_of_5) / sizeof(limb); |
| 2398 | limb_span large = limb_span(large_power_of_5, large_length); |
| 2399 | while (exp >= large_step) { |
| 2400 | FASTFLOAT_TRY(large_mul(vec, large)); |
| 2401 | exp -= large_step; |
| 2402 | } |
| 2403 | #ifdef FASTFLOAT_64BIT_LIMB |
| 2404 | uint32_t small_step = 27; |
| 2405 | limb max_native = 7450580596923828125UL; |
| 2406 | #else |
| 2407 | uint32_t small_step = 13; |
| 2408 | limb max_native = 1220703125U; |
| 2409 | #endif |
| 2410 | while (exp >= small_step) { |
| 2411 | FASTFLOAT_TRY(small_mul(vec, max_native)); |
| 2412 | exp -= small_step; |
| 2413 | } |
| 2414 | if (exp != 0) { |
| 2415 | // Work around clang bug https://godbolt.org/z/zedh7rrhc |
| 2416 | // This is similar to https://github.com/llvm/llvm-project/issues/47746, |
| 2417 | // except the workaround described there don't work here |
| 2418 | FASTFLOAT_TRY( |
| 2419 | small_mul(vec, limb(((void)small_power_of_5[0], small_power_of_5[exp]))) |
| 2420 | ); |
| 2421 | } |
| 2422 | |
| 2423 | return true; |
| 2424 | } |
| 2425 | |
| 2426 | // multiply as if by 10 raised to a power. |
| 2427 | FASTFLOAT_CONSTEXPR20 bool pow10(uint32_t exp) noexcept { |
no test coverage detected