math: cleanup floor.v, remove the last goto in the math module

This commit is contained in:
Delyan Angelov 2025-02-06 09:29:08 +02:00
parent d1ec41cd6a
commit 2b479b5eb0
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -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
}
}