Maybe Lua rounds a bit. Becuase officially lua_Number is a double afaik. In C++ adding them as doubles results in 0.30000000000000004, and adding them as floats results in 0.300000012 according to gdb.
In Pico8, lua numbers use fixed point representation. 16 bits before the decimal and 16 bits after the decimal. Not as flexible as floating point, but way less fiddly. I love it
44
u/9551-eletronics Computercraft graphics research Jul 01 '25
https://imgur.com/iRvwjcV
31
u/AndromedaGalaxy29 Jul 01 '25
What? It's not 0.300000000000001?! Impossible.
10
u/SlimeBOOS Jul 02 '25
Isn't this because Lua uses double precision floating point numbers?
3
u/sciolizer Jul 02 '25
In Pico8, lua numbers use fixed point representation. 16 bits before the decimal and 16 bits after the decimal. Not as flexible as floating point, but way less fiddly. I love it
1
u/mc_jojo3 Jul 02 '25
Holy shit
1
u/Jonaykon Jul 01 '25
???
8
u/Dark_Reaper115 Jul 01 '25
Burn the witch!!!!!