Skip to content

Commit

Permalink
Fix a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jk-jeon committed Feb 24, 2022
1 parent ba65f0e commit 57d9b60
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions include/dragonbox/dragonbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -2055,7 +2055,9 @@ namespace jkj::dragonbox {
// Using an upper bound on xi, we might be able to optimize the division
// better than the compiler; we are computing xi / big_divisor here.
ret_value.significand =
div::divide_by_pow10<kappa + 1, significand_bits + kappa + 2, kappa + 1>(xi);
div::divide_by_pow10<kappa + 1, carrier_uint,
(carrier_uint(1) << (significand_bits + 1)) * big_divisor -
1>(xi);
auto r = std::uint32_t(xi - big_divisor * ret_value.significand);

if (r != 0) {
Expand Down Expand Up @@ -2130,7 +2132,9 @@ namespace jkj::dragonbox {
// Using an upper bound on zi, we might be able to optimize the division better than
// the compiler; we are computing zi / big_divisor here.
ret_value.significand =
div::divide_by_pow10<kappa + 1, significand_bits + kappa + 2, kappa + 1>(zi);
div::divide_by_pow10<kappa + 1, carrier_uint,
(carrier_uint(1) << (significand_bits + 1)) * big_divisor -
1>(zi);
auto const r = std::uint32_t(zi - big_divisor * ret_value.significand);

if (r > deltai) {
Expand Down

0 comments on commit 57d9b60

Please sign in to comment.