[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [NoW] Inf-phobia of Lua bytecode
- From: Alexander Nasonov <alnsn@...>
- Date: Thu, 11 Jul 2019 19:15:55 +0100
Egor Skriptunoff wrote:
> I've noticed that Lua never stores floating point values inf, nan, -0.0 in
> bytecode (in table of constants).
> local x = 5/4 -- constant 1.25 due to constant folding.
> local y = 1/0 -- constants 0, 1 and DIV instruction.
> local z = -0.0 -- constant 0.0 and UNM instruction.
> It seems that Lua intentionally defers possible FP errors until run-time.
> Why such approach was implemented?
I don't know about Lua but when I wrote code to generate x86 assembly
off a custom bytecode, the fact that all constants were finite numbers
was very handy.