You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code: http://play.golang.org/p/uvj_pmygbE prints math.Max(NaN, 0), where NaN is obtained by either math.NaN() or a/a with a := 0.0.
In the second case, the result is 0 instead of the expected NaN.
This issue is shared by math.Min. However, math.IsNaN works fine for both NaN's.
Tested with go 1.4.2 on linux amd64 and with go 1.4.1 in the playground on nacl amd64p32.
The text was updated successfully, but these errors were encountered:
mikioh
changed the title
math.Max(NaN, x) may return x instead of NaN (depending on the bit representation of NaN)
math: Max(NaN, x) may return x instead of NaN (depending on the bit representation of NaN)
Feb 18, 2015
The issue can be traced back to math/dim_amd64.s. Here, checking for NaN is done by comparing the number with 0x7FF8000000000001. Instead, we need a check that works for all NaN bit patterns.
The following code: http://play.golang.org/p/uvj_pmygbE prints
math.Max(NaN, 0)
, where NaN is obtained by eithermath.NaN()
ora/a
witha := 0.0
.In the second case, the result is 0 instead of the expected NaN.
This issue is shared by
math.Min
. However,math.IsNaN
works fine for both NaN's.Tested with go 1.4.2 on linux amd64 and with go 1.4.1 in the playground on nacl amd64p32.
The text was updated successfully, but these errors were encountered: