Log In  


There is a strange bug in v1.1 that returns a decimal value when I do this:

FOR I=0,3 DO
  K = PEEK(I)
  L = BAND(K, 15)
  H = SHR(K, 4)
  PRINT(L)
  PRINT(R)
END

The output is:

0
1
2
3.125
4
5.25
6
7.375

My assumption is rather than converting to an integer and shifting, you're returning i / 2^s without casting to an integer in the result.

1


PICO-8 numbers are fixed point 16.16, so it's expected that SHR will produce fractional values.


That makes a lot of sense, especially considering I was doing stuff like print(0.1+0.2) and it produced a solid 0.3, instead of a crazy floating point number.

This is what I get for simply skimming the documentation.


That's more about PRINT's display rounding... 0.3 is still not exactly representable.


ooh, this is good to know! i never though of that!



[Please log in to post a comment]