| 665 | } |
| 666 | |
| 667 | bool decimal_from_bfloat16(bfloat16_t value, Decimal &out) { |
| 668 | uint16_t bits = value.to_bits(); |
| 669 | const bool negative = (bits & 0x8000u) != 0; |
| 670 | const uint16_t exp_bits = (bits >> 7) & 0xffu; |
| 671 | uint16_t frac = bits & 0x007fu; |
| 672 | if (exp_bits == 0 && frac == 0) { |
| 673 | out = Decimal(); |
| 674 | return true; |
| 675 | } |
| 676 | uint64_t significand = frac; |
| 677 | int32_t exponent = -133; |
| 678 | if (exp_bits != 0) { |
| 679 | significand |= uint64_t{1} << 7; |
| 680 | exponent = static_cast<int32_t>(exp_bits) - 127 - 7; |
| 681 | } |
| 682 | return decimal_from_float_bits(negative, significand, exponent, out); |
| 683 | } |
| 684 | |
| 685 | bool decimal_plain_string(const Decimal &decimal, std::string &out) { |
| 686 | Decimal canonical; |
no test coverage detected