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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...