From 898db2c2784db65ca1e4e6768e6701d8c41ac6dc Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Mon, 27 Jun 2022 22:14:42 +0200 Subject: [PATCH] Bluon: Write out-of-bounds ints as floats --- bluon.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bluon.lua b/bluon.lua index 8e6742b..e8465a0 100644 --- a/bluon.lua +++ b/bluon.lua @@ -1,6 +1,6 @@ -- Localize globals -local assert, error, ipairs, math_floor, math_huge, modlib, next, pairs, setmetatable, string, table_insert, type, unpack - = assert, error, ipairs, math.floor, math.huge, modlib, next, pairs, setmetatable, string, table.insert, type, unpack +local assert, error, ipairs, math_floor, math_abs, math_huge, modlib, next, pairs, setmetatable, string, table_insert, type, unpack + = assert, error, ipairs, math.floor, math.abs, math.huge, modlib, next, pairs, setmetatable, string, table.insert, type, unpack -- Set environment local _ENV = {} @@ -203,7 +203,7 @@ function write(self, value, stream) stream:write(constant_nan) return end - if value % 1 == 0 then + if value % 1 == 0 and math_abs(value) < 2^64 then uint_with_type(value > 0 and type_ranges.number_constant or type_ranges.number_negative, value > 0 and value or -value) return end @@ -332,4 +332,4 @@ function read(self, stream) end -- Export environment -return _ENV \ No newline at end of file +return _ENV