runtime: scan register backing store on ia64
[official-gcc.git] / libgo / go / runtime / float.go
blob459e58dd7ef0af0e475aa456906dd7ffd72fac10
1 // Copyright 2017 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 package runtime
7 import "unsafe"
9 var inf = float64frombits(0x7FF0000000000000)
11 // isNaN reports whether f is an IEEE 754 ``not-a-number'' value.
12 func isNaN(f float64) (is bool) {
13 // IEEE 754 says that only NaNs satisfy f != f.
14 return f != f
17 // isFinite reports whether f is neither NaN nor an infinity.
18 func isFinite(f float64) bool {
19 return !isNaN(f - f)
22 // isInf reports whether f is an infinity.
23 func isInf(f float64) bool {
24 return !isNaN(f) && !isFinite(f)
27 // Abs returns the absolute value of x.
29 // Special cases are:
30 // Abs(±Inf) = +Inf
31 // Abs(NaN) = NaN
32 func abs(x float64) float64 {
33 const sign = 1 << 63
34 return float64frombits(float64bits(x) &^ sign)
37 // copysign returns a value with the magnitude
38 // of x and the sign of y.
39 func copysign(x, y float64) float64 {
40 const sign = 1 << 63
41 return float64frombits(float64bits(x)&^sign | float64bits(y)&sign)
44 // Float64bits returns the IEEE 754 binary representation of f.
45 func float64bits(f float64) uint64 {
46 return *(*uint64)(unsafe.Pointer(&f))
49 // Float64frombits returns the floating point number corresponding
50 // the IEEE 754 binary representation b.
51 func float64frombits(b uint64) float64 {
52 return *(*float64)(unsafe.Pointer(&b))