Pages: 1
In standard Scratch, round(-0.5) rounds to -1
but in the online Java, round(-0.5) rounds to 0.
It would be more predictable if they worked the same. I would have expected that round(-0.5) would round to -1 for both.
Offline
ffrazer wrote:
In standard Scratch, round(-0.5) rounds to -1
but in the online Java, round(-0.5) rounds to 0.
It would be more predictable if they worked the same. I would have expected that round(-0.5) would round to -1 for both.
You may be seeing a case of different internal representaitions leading to different evaluations. There may be no exact representation for -0.5 in one or both environments and the binary approximation may be different enough that they evaluate differently when rounded. Just a theory.
Also, take a look at this project which walks the values up from -1 to +1 by in steps of 0.1 and you can see that round-off error results in a different result than what you describe above.
http://scratch.mit.edu/projects/Paddle2SeeFixIt/325050
Offline
Pages: 1