Fix nearest f32
and f64
again
This commit is contained in:
parent
e6ebb222bf
commit
04d1840d2d
@ -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
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user