aboutsummaryrefslogtreecommitdiff
path: root/src/pkg
diff options
context:
space:
mode:
authorShenghou Ma <minux.ma@gmail.com>2012-08-07 09:57:14 +0800
committerShenghou Ma <minux.ma@gmail.com>2012-08-07 09:57:14 +0800
commit6e9506a7b45958665c3f48deecc8555f3ee2c42b (patch)
tree4cc2d8f39f001caf2b5e78b6483f3a22ebc21a33 /src/pkg
parent41645847b4f5187c088149f1177e8a3fc7d1f373 (diff)
downloadgo-6e9506a7b45958665c3f48deecc8555f3ee2c42b.tar.xz
math, runtime: use a NaN that matches gcc's
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
Diffstat (limited to 'src/pkg')
-rw-r--r--src/pkg/math/all_test.go11
-rw-r--r--src/pkg/math/bits.go2
-rw-r--r--src/pkg/runtime/float.c2
3 files changed, 13 insertions, 2 deletions
diff --git a/src/pkg/math/all_test.go b/src/pkg/math/all_test.go
index 8cbead1ab7..cdea8035f9 100644
--- a/src/pkg/math/all_test.go
+++ b/src/pkg/math/all_test.go
@@ -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
diff --git a/src/pkg/math/bits.go b/src/pkg/math/bits.go
index 1cf60ce7df..0df0b1cc9f 100644
--- a/src/pkg/math/bits.go
+++ b/src/pkg/math/bits.go
@@ -5,7 +5,7 @@
package math
const (
- uvnan = 0x7FF0000000000001
+ uvnan = 0x7FF8000000000001
uvinf = 0x7FF0000000000000
uvneginf = 0xFFF0000000000000
mask = 0x7FF
diff --git a/src/pkg/runtime/float.c b/src/pkg/runtime/float.c
index f481519f65..4d9f125977 100644
--- a/src/pkg/runtime/float.c
+++ b/src/pkg/runtime/float.c
@@ -4,7 +4,7 @@
#include "runtime.h"
-static uint64 uvnan = 0x7FF0000000000001ULL;
+static uint64 uvnan = 0x7FF8000000000001ULL;
static uint64 uvinf = 0x7FF0000000000000ULL;
static uint64 uvneginf = 0xFFF0000000000000ULL;