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.

P#13331 2015-08-30 17:03 ( Edited 2015-08-31 13:29)

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

P#13362 2015-08-30 21:33 ( Edited 2015-08-31 01:33)

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.

P#13371 2015-08-30 22:59 ( Edited 2015-08-31 02:59)

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

P#13374 2015-08-30 23:50 ( Edited 2015-08-31 03:50)

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

P#13384 2015-08-31 09:29 ( Edited 2015-08-31 13:29)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 11:00:01 | 0.006s | Q:13