mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-26 01:03:46 +01:00
Use math constants
This commit is contained in:
parent
9af2d64ad9
commit
eb3a3b2960
@ -2,6 +2,8 @@
|
|||||||
local assert, math_huge, math_frexp, math_floor
|
local assert, math_huge, math_frexp, math_floor
|
||||||
= 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
|
-- Set environment
|
||||||
local _ENV = {}
|
local _ENV = {}
|
||||||
setfenv(1, _ENV)
|
setfenv(1, _ENV)
|
||||||
@ -34,8 +36,7 @@ function read_float(read_byte, double)
|
|||||||
return sign * math_huge
|
return sign * math_huge
|
||||||
end
|
end
|
||||||
-- Differentiating quiet and signalling nan is not possible in Lua, hence we don't have to do it
|
-- 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 positive_nan or negative_nan
|
||||||
return sign == 1 and ((0/0)^1) or 0/0
|
|
||||||
end
|
end
|
||||||
assert(mantissa < 1)
|
assert(mantissa < 1)
|
||||||
if exponent == 0 then
|
if exponent == 0 then
|
||||||
|
Loading…
Reference in New Issue
Block a user