Jump to content

Numerical Rounding Errors


wowgetoffyourcellphone
 Share

Recommended Posts

1 hour ago, wowgetoffyourcellphone said:

Post them when ya got em. This seems to be a recurring issue with the development of the game where rounding errors always seem to crop up. lol

Interestingly, this is not present in A23; there trade gain is displayed as an integer. I don't now when or what introduced those decimals in A24.

Link to comment
Share on other sites

If I might suggest something, you might wanna look into that commit which added the manager thing. In this case, this is just a missed rounding as opposed to an actual error. *just to clarify, I am not saying that its what caused the problem. Just saying that its a possibility. I dont care enough to go through commit logs lol.


 

Spoiler

 

[stuff nobody asked for]

Unfortunately, floating point errors are not specific to JS. Using double precision, 0.1 + 0.2 = 0.30000000000000004. Python, JS, C++, whatever.

1/5 = 0.2 in base 10.

In base 2, its 0.00110011001100110011001100110011001100110011001100110011... and it goes on infinitely. In the IEEE 752 standard, the significand is 53 bits, the rest is cut off.

Same as when you cant get exactly 1 when you add 1/3 + 1/3 + 1/3 together in a calculator which does not round off.

[/stuff nobody asked for]

 

 

Edited by smiley
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...