Live data from Hacker News

9999999999999999.0 – 9999999999999998.0

geocar.sdf1.org

81–83 of 83 posts

Re: 9999999999999999.0 – 9999999999999998.0

#81
post #13
post #5

Earlier quoted context omitted.

> And it almost never matters. I take issue with this. Drift from floating point inaccuracies can compound quickly and dramatically affect results. Sure if you're just looping over a 1000 item list, it's not going to matter that JavaScript is representing that as a float/double, but in a wide variety of contexts, such as anything to do with money, it absolutely does matter.

Another example is open world games. They have to keep world coordinates centered on the player because for large worlds, the floating point inaccuracy in the far reaches of the world starts to really matter. An example of a game that does this is Outer Wilds.

caveat: this is not my direct experience so i might be wrong -- but someone who was doing an different masters project at the same time as mine was doing a mini on-rails video game and mentioned this.

apparently it's also because of the "what is up?" question.

e.g. in outer wilds ... how do you determine which way is "up" when "up" for the player can be any direction.

Re: 9999999999999999.0 – 9999999999999998.0

#82
post #37
post #34

Earlier quoted context omitted.

Could you please explain me why 2 would be the correct answer?

Parsing the provided numbers to two IEEE 754 double-precision floats, and then subtracting them, yields 2.0 (due to rounding) In particular, 9999999999999999.0 rounds up to 10000000000000000.0 (note, this behavior depends on the rounding mode, https://en.wikipedia.org/wiki/IEEE_754#Rounding_rules )

But here rounding is giving you the wrong answer.
Post reply on HN