diff --git a/src/core/strtod.c b/src/core/strtod.c index 78f9c8f0..9cfe09f8 100644 --- a/src/core/strtod.c +++ b/src/core/strtod.c @@ -208,9 +208,9 @@ static double convert( /* Approximate exponent in base 2 of mant and exponent. This should get us a good estimate of the final size of the * number, within * 2^32 or so. */ - int32_t mant_exp2_approx = mant->n * 32 + 16; - int32_t exp_exp2_approx = (int32_t)(floor(log2(base) * exponent)); - int32_t exp2_approx = mant_exp2_approx + exp_exp2_approx; + int64_t mant_exp2_approx = mant->n * 32 + 16; + int64_t exp_exp2_approx = (int64_t)(floor(log2(base) * exponent)); + int64_t exp2_approx = mant_exp2_approx + exp_exp2_approx; /* Short circuit zero, huge, and small numbers. We use the exponent range of valid IEEE754 doubles (-1022, 1023) * with a healthy buffer to allow for inaccuracies in the approximation and denormailzed numbers. */ diff --git a/test/suite8.janet b/test/suite8.janet index 591427ee..3a982f08 100644 --- a/test/suite8.janet +++ b/test/suite8.janet @@ -241,4 +241,7 @@ neldb\0\0\0\xD8\x05printG\x01\0\xDE\xDE\xDE'\x03\0marshal_tes/\x02 (assert (nil? (first @"")) "in vs get 1") (assert (nil? (last @"")) "in vs get 1") +# For undefined behavior sanitizer +0xf&1fffFFFF + (end-suite)