diff --git a/ryu/d2s.c b/ryu/d2s.c index de89c8bb..9f6ae996 100644 --- a/ryu/d2s.c +++ b/ryu/d2s.c @@ -307,11 +307,10 @@ static inline floating_decimal_64 d2d(const uint64_t ieeeMantissa, const uint32_ --vp; } } else if (q < 63) { // TODO(ulfjack): Use a tighter bound here. - // We need to compute min(ntz(mv), pow5Factor(mv) - e2) >= q - 1 - // <=> ntz(mv) >= q - 1 && pow5Factor(mv) - e2 >= q - 1 - // <=> ntz(mv) >= q - 1 (e2 is negative and -e2 >= q) - // <=> (mv & ((1 << (q - 1)) - 1)) == 0 - // We also need to make sure that the left shift does not overflow. + // We want to know if the full product has at least q trailing zeros. + // We need to compute min(p2(mv), p5(mv) - e2) >= q + // <=> p2(mv) >= q && p5(mv) - e2 >= q + // <=> p2(mv) >= q (because -e2 >= q) vrIsTrailingZeros = multipleOfPowerOf2(mv, q); #ifdef RYU_DEBUG printf("vr is trailing zeros=%s\n", vrIsTrailingZeros ? "true" : "false");