From 74011a85c28f1df89ca68d94635b383aec3bb24e Mon Sep 17 00:00:00 2001 From: Pinya <800pin.ru@gmail.com> Date: Thu, 15 Feb 2018 21:18:51 +0300 Subject: [PATCH] =?UTF-8?q?fix=20math.modf=20in=20case=20value=20equal=200?= =?UTF-8?q?=20or=20=C2=B1Inf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- !Compatibility/api/luaAPI.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/!Compatibility/api/luaAPI.lua b/!Compatibility/api/luaAPI.lua index c3f467c..b2f0ea2 100644 --- a/!Compatibility/api/luaAPI.lua +++ b/!Compatibility/api/luaAPI.lua @@ -46,11 +46,20 @@ function select(n, ...) return unpack(args) end +local huge = math.huge function math.modf(i) + i = type(i) ~= "number" and tonumber(i) or i + if type(i) ~= "number" then error(format("bad argument #1 to 'modf' (number expected, got %s)", i and type(i) or "no value"), 2) 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) return int, i - int