[0.16.36] Rounding error with modules?
[0.16.36] Rounding error with modules?
Hi,
I wanted to point out an assembler 3 with 2x speed3 modules is showing up energy consumption of 504 kW (correctly), but as soon as you add a 3rd speed3 module (or more), it seems to lose a kW.
With 3x speed3 it should be using 210 * (1 + 3 * 70%) = 651 kW, but the info box (shown when you hover mouse over the building) shows only 650 kW. With 4 modules, it should be 798 kW, but shows only 797.
Is it just a display issue, or is it actually taking the wrong amount of power?
It's quite peculiar as there should be no fractions or rounding going on there anywhere - the result is an exact number, and one module increases power usage by exactly 147 kW (no fractions or rounding either). Even if you divide 210 by 7 or 70 incorrectly first (to later multiply it by 10 or 100, which you should have done as the first step), you still end up with no fractions on the way.
I wanted to point out an assembler 3 with 2x speed3 modules is showing up energy consumption of 504 kW (correctly), but as soon as you add a 3rd speed3 module (or more), it seems to lose a kW.
With 3x speed3 it should be using 210 * (1 + 3 * 70%) = 651 kW, but the info box (shown when you hover mouse over the building) shows only 650 kW. With 4 modules, it should be 798 kW, but shows only 797.
Is it just a display issue, or is it actually taking the wrong amount of power?
It's quite peculiar as there should be no fractions or rounding going on there anywhere - the result is an exact number, and one module increases power usage by exactly 147 kW (no fractions or rounding either). Even if you divide 210 by 7 or 70 incorrectly first (to later multiply it by 10 or 100, which you should have done as the first step), you still end up with no fractions on the way.
Re: [0.16.36] Rounding error with modules?
What's more bizarre, is that the game is perfectly capable of displaying fractions there, BUT DISPLAYS THEM WRONG! For instance if you max out Efficiency modules to get the -80% energy bonus, the game shows "41.9 kW", instead of 210 * 20% = 42!
This particular example smells like it's trying to avoid the answer to the ultimate question of life, the universe, and everything?
This particular example smells like it's trying to avoid the answer to the ultimate question of life, the universe, and everything?
Re: [0.16.36] Rounding error with modules?
This is most likely a result of imperfect representation of real numbers. 80 % is 0.8, which cannot be represented in binary and becomes 0.80000001192092895508 when forced into a float type variable.
1 - 0.80000001192092895508 = 0.19999998808
210 * 0.19999998808 = 41.9999974968
Truncate the fractional part to one digit and you get 41.9.
Maybe the game isn’t rounding that properly? It should obviously be rounded up to 42.
1 - 0.80000001192092895508 = 0.19999998808
210 * 0.19999998808 = 41.9999974968
Truncate the fractional part to one digit and you get 41.9.
Maybe the game isn’t rounding that properly? It should obviously be rounded up to 42.
Re: [0.16.36] Rounding error with modules?
The game doesn't round numbers.kitcat wrote:This is most likely a result of imperfect representation of real numbers. 80 % is 0.8, which cannot be represented in binary and becomes 0.80000001192092895508 when forced into a float type variable.
1 - 0.80000001192092895508 = 0.19999998808
210 * 0.19999998808 = 41.9999974968
Truncate the fractional part to one digit and you get 41.9.
Maybe the game isn’t rounding that properly? It should obviously be rounded up to 42.
If you want to get ahold of me I'm almost always on Discord.
Re: [0.16.36] Rounding error with modules?
U sure? I remember seeing some tolerances = rounding around research.Rseding91 wrote:The game doesn't round numbers.kitcat wrote:This is most likely a result of imperfect representation of real numbers. 80 % is 0.8, which cannot be represented in binary and becomes 0.80000001192092895508 when forced into a float type variable.
1 - 0.80000001192092895508 = 0.19999998808
210 * 0.19999998808 = 41.9999974968
Truncate the fractional part to one digit and you get 41.9.
Maybe the game isn’t rounding that properly? It should obviously be rounded up to 42.
Re: [0.16.36] Rounding error with modules?
Maybe not internally, but it at least does something for display. If it doesn’t round(), does it floor()?Rseding91 wrote:The game doesn't round numbers.
Re: [0.16.36] Rounding error with modules?
I call floor(41.999) an "improper rounding" of that number :-) Especially when the result is 41.9. That's definitely incorrect, even for a floor :-)
Re: [0.16.36] Rounding error with modules?
just do floor(41.9999+0.5f) that should do the right thing...
Re: [0.16.36] Rounding error with modules?
Unless one of the other devs wants to tinker with this and potentially break a bunch of stuff (ALA rail signals) I'm going to move this to won't fix.
If you want to get ahold of me I'm almost always on Discord.
Re: [0.16.36] Rounding error with modules?
OK, but can you please let me know what's the actual power it's consuming? I'm doing some other calculations that rely on this. Thanks!
Re: [0.16.36] Rounding error with modules?
A minuscule fraction of a KW less than one more than is displayed.uukgoblin wrote:OK, but can you please let me know what's the actual power it's consuming? I'm doing some other calculations that rely on this. Thanks!
Also... the rail signal thing is the kind of thing that in many games would get put into a stable release, when found the devs would say "just replace all your rail signals", and would get fixed 20 bugfix versions and 5 years later.
So I wouldn't say that it's as bad as you're making it out to be. Literally the only thing you're promising in experimental versions is that your computer probably won't explode.
There are 10 types of people: those who get this joke and those who don't.