Closed Kan18 closed 1 year ago
Mostly noting this down because I was curious what the right behaviour was here:
%q
by converting the value to a string and quoting it. This means ("%q"):format(0/0)
evaluates to "nan"
(or possibly "-nan"
).1e999
behaviour).I kinda wonder if we should do this properly and add support for floating point hex literals.
I've added support for hex literals, but occurs to me doing %q
properly also requires supporting %a
/%A
(or at least a subset of it). This doesn't actually look too hard to get right, which is a relief at least.
Sorry for the delay in looking at this, looks good to me! Thank you <3.
The q specifier should format numbers such that they are a valid constant in Lua code. Previously, Infinity and NaN fell back to Double.toHexString which returns "Infinity" or "NaN", so these cases should be handled separately (matching PUC Lua behavior here).