aboutsummaryrefslogtreecommitdiff
path: root/builtin/common/serialize.lua
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/common/serialize.lua')
-rw-r--r--builtin/common/serialize.lua11
1 files changed, 2 insertions, 9 deletions
diff --git a/builtin/common/serialize.lua b/builtin/common/serialize.lua
index 163aa67ad..300b394c6 100644
--- a/builtin/common/serialize.lua
+++ b/builtin/common/serialize.lua
@@ -120,15 +120,8 @@ function core.serialize(x)
elseif tp == "function" then
return string.format("loadstring(%q)", string.dump(x))
elseif tp == "number" then
- -- Serialize integers with string.format to prevent
- -- scientific notation, which doesn't preserve
- -- precision and breaks things like node position
- -- hashes. Serialize floats normally.
- if math.floor(x) == x then
- return string.format("%d", x)
- else
- return tostring(x)
- end
+ -- Serialize numbers reversibly with string.format
+ return string.format("%.17g", x)
elseif tp == "table" then
local vals = {}
local idx_dumped = {}