Skip to content

Commit

Permalink
math: cleanup floor.v, remove the last goto in the math module
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Feb 6, 2025
1 parent d1ec41c commit 2b479b5
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions vlib/math/floor.v
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,13 @@ pub fn round(x f64) f64 {
mut y := floor(x) // Fractional part
mut r := x - y // Round up to nearest.
if r > 0.5 {
unsafe {
goto rndup
}
y += 1.0
return y
}
// Round to even
if r == 0.5 {
r = y - 2.0 * floor(0.5 * y)
if r == 1.0 {
rndup:
y += 1.0
}
}
Expand Down

0 comments on commit 2b479b5

Please sign in to comment.