Fix nearest f32 and f64 again

This commit is contained in:
Rerumu 2022-06-28 02:03:29 -04:00
parent e6ebb222bf
commit 04d1840d2d
2 changed files with 7 additions and 3 deletions

View File

@ -138,8 +138,12 @@ do
function nearest.f32(num) function nearest.f32(num)
local result = round(num) local result = round(num)
if math_abs(num) % 1 == 0.5 and result % 2 == 1 then if (math_abs(num) + 0.5) % 2 == 1 then
if result >= 0 then
result = result - 1 result = result - 1
else
result = result + 1
end
end end
return result return result

View File

@ -151,7 +151,7 @@ do
function nearest.f32(num) function nearest.f32(num)
local result = math_round(num) local result = math_round(num)
if math_abs(num) % 1 == 0.5 and math_floor(math_abs(num) % 2) == 0 then if (math_abs(num) + 0.5) % 2 == 1 then
result = result - math_sign(result) result = result - math_sign(result)
end end