lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 20/06/2023 16:14, Hugo Musso Gualandi wrote:
In Pallene we try from "%.6g" to "%.17g" and pick the smallest one that round-trips to the original number. (We can't use %a because our output is C, not Lua).

Are you bound to C89? C99 has %a:

Currently we do try to support c89.  Also, we found that using decimal when possible was more readable :)

By the way, beware that "%a" doesn't always produce something that's a valid C or Lua literal. For example, it might return "inf" or "-nan".