1
0
mirror of https://github.com/golang/go synced 2024-11-25 04:17:57 -07:00

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
This commit is contained in:
Shenghou Ma 2012-08-07 09:57:14 +08:00
parent 41645847b4
commit 6e9506a7b4
3 changed files with 13 additions and 2 deletions

View File

@ -1693,6 +1693,17 @@ func alike(a, b float64) bool {
return false 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) { func TestAcos(t *testing.T) {
for i := 0; i < len(vf); i++ { for i := 0; i < len(vf); i++ {
a := vf[i] / 10 a := vf[i] / 10

View File

@ -5,7 +5,7 @@
package math package math
const ( const (
uvnan = 0x7FF0000000000001 uvnan = 0x7FF8000000000001
uvinf = 0x7FF0000000000000 uvinf = 0x7FF0000000000000
uvneginf = 0xFFF0000000000000 uvneginf = 0xFFF0000000000000
mask = 0x7FF mask = 0x7FF

View File

@ -4,7 +4,7 @@
#include "runtime.h" #include "runtime.h"
static uint64 uvnan = 0x7FF0000000000001ULL; static uint64 uvnan = 0x7FF8000000000001ULL;
static uint64 uvinf = 0x7FF0000000000000ULL; static uint64 uvinf = 0x7FF0000000000000ULL;
static uint64 uvneginf = 0xFFF0000000000000ULL; static uint64 uvneginf = 0xFFF0000000000000ULL;