| 590 | } |
| 591 | |
| 592 | bool decimal_from_float_bits(bool negative, uint64_t significand, |
| 593 | int32_t exponent, Decimal &out) { |
| 594 | BigUInt magnitude = BigUInt::from_uint64(significand); |
| 595 | if (exponent >= 0) { |
| 596 | for (int32_t i = 0; i < exponent; ++i) { |
| 597 | magnitude.multiply(2); |
| 598 | } |
| 599 | return canonical_decimal(std::move(magnitude), negative, 0, out); |
| 600 | } |
| 601 | const int32_t scale = -exponent; |
| 602 | if (scale > MAX_COMPATIBLE_DECIMAL_DIGITS) { |
| 603 | return false; |
| 604 | } |
| 605 | for (int32_t i = 0; i < scale; ++i) { |
| 606 | magnitude.multiply(5); |
| 607 | } |
| 608 | return canonical_decimal(std::move(magnitude), negative, scale, out); |
| 609 | } |
| 610 | |
| 611 | bool decimal_from_float32(float value, Decimal &out) { |
| 612 | uint32_t bits = 0; |
no test coverage detected