mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
fix math.modf in case value equal 0 or ±Inf
This commit is contained in:
@@ -46,11 +46,20 @@ function select(n, ...)
|
|||||||
return unpack(args)
|
return unpack(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local huge = math.huge
|
||||||
function math.modf(i)
|
function math.modf(i)
|
||||||
|
i = type(i) ~= "number" and tonumber(i) or i
|
||||||
|
|
||||||
if type(i) ~= "number" then
|
if type(i) ~= "number" then
|
||||||
error(format("bad argument #1 to 'modf' (number expected, got %s)", i and type(i) or "no value"), 2)
|
error(format("bad argument #1 to 'modf' (number expected, got %s)", i and type(i) or "no value"), 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if i == 0 then
|
||||||
|
return i, i
|
||||||
|
elseif abs(i) == huge then
|
||||||
|
return i, i > 0 and 0 or -0
|
||||||
|
end
|
||||||
|
|
||||||
local int = i >= 0 and floor(i) or ceil(i)
|
local int = i >= 0 and floor(i) or ceil(i)
|
||||||
|
|
||||||
return int, i - int
|
return int, i - int
|
||||||
|
|||||||
Reference in New Issue
Block a user