Add Ceil{,32} and Floor{,32}.
This commit is contained in:
parent
cc2addf7e2
commit
17af2eb843
20
math.go
20
math.go
@ -2,6 +2,10 @@ package geom
|
||||
|
||||
import "math"
|
||||
|
||||
func emulate32(f float32, fn func(float64) float64) float32 {
|
||||
return float32(fn(float64(f)))
|
||||
}
|
||||
|
||||
// Abs returns the absolute value.
|
||||
func Abs(f float64) float64 {
|
||||
return math.Abs(f)
|
||||
@ -22,6 +26,14 @@ func Atan32(f float32) float32 {
|
||||
return float32(math.Atan(float64(f)))
|
||||
}
|
||||
|
||||
// Ceil rounds f up to an natural number.
|
||||
func Ceil(f float64) float64 {
|
||||
return math.Ceil(f)
|
||||
}
|
||||
|
||||
// Ceil32 rounds f up to an natural number.
|
||||
func Ceil32(f float32) float32 { return emulate32(f, math.Ceil) }
|
||||
|
||||
// Cos returns the cosine of f.
|
||||
func Cos(f float64) float64 {
|
||||
return math.Cos(f)
|
||||
@ -32,6 +44,14 @@ func Cos32(f float32) float32 {
|
||||
return float32(math.Cos(float64(f)))
|
||||
}
|
||||
|
||||
// Floor rounds f down to an natural number.
|
||||
func Floor(f float64) float64 {
|
||||
return math.Floor(f)
|
||||
}
|
||||
|
||||
// Floor32 rounds f down to an natural number.
|
||||
func Floor32(f float32) float32 { return emulate32(f, math.Floor) }
|
||||
|
||||
// IsNaN checks if the floating point number is not a number.
|
||||
func IsNaN(f float64) bool {
|
||||
return f != f
|
||||
|
Loading…
Reference in New Issue
Block a user