lua-users home
lua-l archive

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


suggestion to use


https://web.tecgraf.puc-rio.br/~lhf/ftp/lua/
lbc
A simple arbitrary-precision library for Lua based on GNU bc.
5.x
lbn
An arbitrary-precision integer library for Lua based on OpenSSL bn.
5.x
limath
An arbitrary-precision integer library for Lua based on imath.
5.x
lint64
A library for using 64-bit integers in Lua.
5.x

https://gmplib.org/





---- Em Ter, 20 jun 2023 12:53:50 -0300 Lorenzo Donati <lorenzodonatibz@tiscali.it> escreveu ---



On 20/06/2023 17:14, Hugo Musso Gualandi wrote:
>
>> 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:
>>
>> https://en.cppreference.com/w/c/io/fprintf
>
> 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".

Yep, that's why I mentioned C99 and strtod. In C99 strtod can convert
"inf" and "nan" to actual float infinities and NaNs.

IDK if Lua uses strtod internally to implement "tonumber", but if it
does and it is compiled as C99 it should (could?) support also "nan" and
"inf".