chiark / gitweb /
TOML::Tiny: Try to be more faithful for small decimals
Ideally, if we read a TOML file and write it back out again, we get a
semantically equivalent TOML file. Here we improve the situation
for smallish deciaml integers.
We check for values that round trip from string through a perl integer
and back to the same string; if they do, return that integer rather
than the string.
The main point of this check is to avoid losing information if the
value is too large to fit into a Perl integer, which might be only
32-bit.
This technique is not perfect: it can't cope with hex, octal or
binary, or with larger values that would need bignums. But it is an
improvement and probably the best that can be done without
unreasonable effort.