mirror of
https://github.com/Luzifer/nginx-sso.git
synced 2024-12-30 09:41:19 +00:00
14 lines
308 B
Go
14 lines
308 B
Go
package float
|
|
|
|
import "math"
|
|
|
|
// Round returns a float rounded according to "Round to nearest, ties away from zero" IEEE floaing point rounding rule
|
|
func Round(x float64) float64 {
|
|
var absx, y float64
|
|
absx = math.Abs(x)
|
|
y = math.Floor(absx)
|
|
if absx-y >= 0.5 {
|
|
y += 1.0
|
|
}
|
|
return math.Copysign(y, x)
|
|
}
|