Added {Is,}NaN{,32} methods.
This commit is contained in:
parent
8bcc0dff3f
commit
060dd4380c
23
math.go
Normal file
23
math.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package geom
|
||||||
|
|
||||||
|
import "math"
|
||||||
|
|
||||||
|
// IsNaN checks if the floating point number is not a number.
|
||||||
|
func IsNaN(f float64) bool {
|
||||||
|
return f != f
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsNaN32 checks if the floating point number is not a number.
|
||||||
|
func IsNaN32(f float32) bool {
|
||||||
|
return f != f
|
||||||
|
}
|
||||||
|
|
||||||
|
// NaN returns not a floating point number.
|
||||||
|
func NaN() float64 {
|
||||||
|
return math.NaN()
|
||||||
|
}
|
||||||
|
|
||||||
|
// NaN32 returns not a floating point number.
|
||||||
|
func NaN32() float32 {
|
||||||
|
return float32(NaN())
|
||||||
|
}
|
14
math_test.go
Normal file
14
math_test.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package geom_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"opslag.de/schobers/geom"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIsNaN32(t *testing.T) {
|
||||||
|
assert.True(t, geom.IsNaN32(geom.NaN32()))
|
||||||
|
assert.False(t, geom.IsNaN32(0))
|
||||||
|
assert.False(t, geom.IsNaN32(-1.43994e8))
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user