Hi, I have a trouble with floating point arithmetic.
function _draw() cls() print( 256 / 65536 * 256 ) print( 256 / (256*256) ) end
This snipet output "-2" and "32768".
Why this snipet dosn't output "1" and "0.00390625" ?
I try same thing on lua demopage.
It outputs "0.00390625".
PICO-8 doesn't use the same number representation as regular Lua, so the Lua demo page exhibits different behavior.
Lua's numbers are 64-bit floating-point numbers. However, PICO-8's numbers are fixed-point, with 16 bits before the decimal point (-32767 to 32768), and 16 bits after the decimal points.
Ah ! This actually answers the question on why my earlier code of counting high numbers failed only in the BBS but not in immediate cart.
And later when I recoded it where no actual high numbers were used, it didn't:
Thanks, WaterSplash ! That was very helpful.
It's probably not a good idea to skirt 32767 or -32767, much like sailing ships reaching the ends of the earth.
There be monsters ...
[Please log in to post a comment]