mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-11-18 17:17:31 +00:00
Change JSON number formatting to be more conform
This commit is contained in:
parent
6f2be8486e
commit
9406b598f8
@ -53,7 +53,15 @@ end
|
|||||||
---@param val number
|
---@param val number
|
||||||
---@return string
|
---@return string
|
||||||
function lib.MarshalNumber(val)
|
function lib.MarshalNumber(val)
|
||||||
-- TODO: Marshal NaN, +Inf, -Inf, ... correctly
|
-- Edge cases, as there is no real solution to this.
|
||||||
|
-- JSON can't store special IEEE754 values, this is dumb as hell.
|
||||||
|
if val ~= val then
|
||||||
|
return "null" -- Alternatively we could output the string "NaN" (With quotes).
|
||||||
|
elseif val <= -math.huge then
|
||||||
|
return "-1E+600" -- Just output a stupidly large number.
|
||||||
|
elseif val >= math.huge then
|
||||||
|
return "1E+600" -- Just output a stupidly large number.
|
||||||
|
end
|
||||||
|
|
||||||
return tostring(val)
|
return tostring(val)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user