Skip to content

Commit 45f44e1

Browse files
Fix round result for positive zero (#87)
1 parent 592312d commit 45f44e1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

mgl32/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func SetMax(a, b *float32) {
137137
func Round(v float32, precision int) float32 {
138138
p := float64(precision)
139139
t := float64(v) * math.Pow(10, p)
140-
if t > 0 {
140+
if t >= 0 {
141141
return float32(math.Floor(t+0.5) / math.Pow(10, p))
142142
}
143143
return float32(math.Ceil(t-0.5) / math.Pow(10, p))

mgl64/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func SetMax(a, b *float64) {
139139
func Round(v float64, precision int) float64 {
140140
p := float64(precision)
141141
t := float64(v) * math.Pow(10, p)
142-
if t > 0 {
142+
if t >= 0 {
143143
return float64(math.Floor(t+0.5) / math.Pow(10, p))
144144
}
145145
return float64(math.Ceil(t-0.5) / math.Pow(10, p))

0 commit comments

Comments
 (0)