From eb3a3b296028b03d3ac0bd1b5b9ccdbe759531ee Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Mon, 9 Aug 2021 13:58:10 +0200 Subject: [PATCH] Use math constants --- binary.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/binary.lua b/binary.lua index 03bdd67..c8d7f47 100644 --- a/binary.lua +++ b/binary.lua @@ -2,6 +2,8 @@ local assert, math_huge, math_frexp, math_floor = assert, math.huge, math.frexp, math.floor +local positive_nan, negative_nan = modlib.math.positive_nan, modlib.math.negative_nan + -- Set environment local _ENV = {} setfenv(1, _ENV) @@ -34,8 +36,7 @@ function read_float(read_byte, double) return sign * math_huge end -- Differentiating quiet and signalling nan is not possible in Lua, hence we don't have to do it - -- HACK ((0/0)^1) yields nan, 0/0 yields -nan - return sign == 1 and ((0/0)^1) or 0/0 + return sign == 1 and positive_nan or negative_nan end assert(mantissa < 1) if exponent == 0 then