Semih
Semih

Reputation: 33

Are hard-coded math operations performed at compile time or run time in lua

I know not all compilers do that but does lua do it?

I have this written 15 * 1.75 * 2 I can just leave a comment line and leave the calculation there, in order make it still understandable but leaving it like the way it is better and I am curious.

Upvotes: 2

Views: 82

Answers (1)

ESkri
ESkri

Reputation: 1888

Math expressions are calculated at compile time in Lua 5.1+ (thanks to Luke100000 for the link in the comments).
The only exceptions are infs and NaN. A Lua bytecode contains only finite numeric constants; "dangerous" math operations resulting in inf/NaN are deferred to runtime.

Upvotes: 3

Related Questions