From 5382a22e0eea878339c504b2a9a3b36bcd839fcc Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 28 Aug 2018 12:36:58 -0300 Subject: Corrections in the implementation of '%' for floats. The multiplication (m*b) used to test whether 'm' is non-zero and 'm' and 'b' have different signs can underflow for very small numbers, giving a wrong result. The use of explicit comparisons solves this problem. This commit also adds several new tests for '%' (both for floats and for integers) to exercise more corner cases, such as very large and very small values. --- lvm.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lvm.h') diff --git a/lvm.h b/lvm.h index d58daacd..8ead0c50 100644 --- a/lvm.h +++ b/lvm.h @@ -116,6 +116,7 @@ LUAI_FUNC void luaV_execute (lua_State *L, CallInfo *ci); LUAI_FUNC void luaV_concat (lua_State *L, int total); LUAI_FUNC lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y); LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y); +LUAI_FUNC lua_Number luaV_modf (lua_State *L, lua_Number x, lua_Number y); LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y); LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); -- cgit v1.2.3-55-g6feb