Skip to content

Commit

Permalink
Better exponent printing
Browse files Browse the repository at this point in the history
  • Loading branch information
jk-jeon committed Sep 2, 2024
1 parent 2fa4826 commit 81f7335
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions source/dragonbox_to_chars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,12 +522,10 @@ namespace jkj {
if (exponent >= 100) {
// d1 = exponent / 10; d2 = exponent % 10;
// 6554 = ceil(2^16 / 10)
auto prod = stdr::uint_least32_t(exponent) * UINT32_C(6554);
auto d1 = int(prod >> 16);
prod = (prod & UINT16_C(0xffff)) * 5; // * 10
auto d2 = int(prod >> 15); // >> 16
print_2_digits(d1, buffer);
print_1_digit(d2, buffer + 2);
auto d1 = (std::uint_least32_t(exponent) * UINT32_C(6554)) >> 16;
auto d2 = std::uint_least32_t(exponent) - UINT32_C(10) * d1;
print_2_digits(int(d1), buffer);
print_1_digit(int(d2), buffer + 2);
buffer += 3;
}
else if (exponent >= 10) {
Expand Down

0 comments on commit 81f7335

Please sign in to comment.