math/big: Float.Float64() may not round correctly for values near math.SmallestNonzeroFloat64 #44058
Comments
i think it's a mistake, in golang compile, the math.SmallestNonzeroFloat64 / 2 will use big.Float to calculate multi-precision floating, and when transform to float64 the precision will loss, so the print will undefined. and your example use big.Rat, it's different |
math.SmallestNonzeroFloat64 / 2 is a special example will rounding to math.SmallestNonzeroFloat64, the logic is here。change the
|
Change https://golang.org/cl/288672 mentions this issue: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The compiler constant expression
gets printed as
5e-324
(program), but the exact computation ofmath.SmallestNonzeroFloat64 / 2
usingmath/big
arithmetic followed by rounding results in0
(program).There's either an error with the rounding or constant arithmetic somewhere, or a mistake in my assumptions.
This affects a test case in
types2/testdata/const1.src
.The text was updated successfully, but these errors were encountered: