Log In  


how do i test for big numbers that print different than their true value?

function _init()
 srand(39)
 a=rnd(-1) --prints -20954.2428
 b=-20954.2428
end

function draw()
 if b==a then
  ?"true"
 else
  ?"false"
 end  --prints false
end

I have some big numbers that would be nice to know their true value.
thanks and merry Christmas!



2

Decimal values printed in PICO-8 are automatically rounded to 4 decimal places, and due to PICO-8's fixed "16.16" precision, not all decimal fractional values can be perfectly represented. You can use tostr(mynumber,1) to get a string representing the true value in hexadecimal without any rounding.


thanks a bunch @kozm0naut! works perfect for what I need



[Please log in to post a comment]