]> Cypherpunks repositories - gostls13.git/commitdiff
math, runtime: use a NaN that matches gcc's
authorShenghou Ma <minux.ma@gmail.com>
Tue, 7 Aug 2012 01:57:14 +0000 (09:57 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Tue, 7 Aug 2012 01:57:14 +0000 (09:57 +0800)
        our old choice is not working properly at least on VFPv2 in
ARM1136JF-S (it's not preserved across float64->float32 conversions).

        Fixes #3745.

R=dave, rsc
CC=golang-dev
https://golang.org/cl/6344078

src/pkg/math/all_test.go
src/pkg/math/bits.go
src/pkg/runtime/float.c

index 8cbead1ab706630ad2927b7cc54a11e3ce720922..cdea8035f9ab33423c4566f8860005d4159c3edb 100644 (file)
@@ -1693,6 +1693,17 @@ func alike(a, b float64) bool {
        return false
 }
 
+func TestNaN(t *testing.T) {
+       f64 := NaN()
+       if f64 == f64 {
+               t.Fatalf("NaN() returns %g, expected NaN", f64)
+       }
+       f32 := float32(f64)
+       if f32 == f32 {
+               t.Fatalf("float32(NaN()) is %g, expected NaN", f32)
+       }
+}
+
 func TestAcos(t *testing.T) {
        for i := 0; i < len(vf); i++ {
                a := vf[i] / 10
index 1cf60ce7df29c49e7a1c9cb21563917255faf12a..0df0b1cc9f124b4078491d02fc547bc7f2aed951 100644 (file)
@@ -5,7 +5,7 @@
 package math
 
 const (
-       uvnan    = 0x7FF0000000000001
+       uvnan    = 0x7FF8000000000001
        uvinf    = 0x7FF0000000000000
        uvneginf = 0xFFF0000000000000
        mask     = 0x7FF
index f481519f6520c7b981263cf5a1871d4ee72480de..4d9f1259771c31ccb1167f4925d5e39a3d78dcee 100644 (file)
@@ -4,7 +4,7 @@
 
 #include "runtime.h"
 
-static uint64  uvnan           = 0x7FF0000000000001ULL;
+static uint64  uvnan           = 0x7FF8000000000001ULL;
 static uint64  uvinf           = 0x7FF0000000000000ULL;
 static uint64  uvneginf        = 0xFFF0000000000000ULL;