I have filled a cryogenic plant to the brim with legendary productivity module 3, and selected the promethium science pack as the recipe. I would expect that this results in an output of 2.4/s, as confirmed by FactorioLab, but instead I get:
The numbers for the input are also off -- that should be "0.8", "0.08", and "2", respectively.
Is this just a visual glitch or will this actually run ever so slightly too slow?
[2.0.43] Odd rounding effects in assembly machine crafting speed display
-
Ralfinator
- Long Handed Inserter

- Posts: 73
- Joined: Sun Jun 26, 2016 9:37 pm
- Contact:
Re: [2.0.43] Odd rounding effects in assembly machine crafting speed display
Thanks for the report. This is simply how floating point numbers work. After all the math is done, what an infinite fraction system would say ends up as “2” may end up 1.999999998 and when showing the numbers as strings it shows only one decimal place.
If you want to get ahold of me I'm almost always on Discord.
-
Ralfinator
- Long Handed Inserter

- Posts: 73
- Joined: Sun Jun 26, 2016 9:37 pm
- Contact:
Re: [2.0.43] Odd rounding effects in assembly machine crafting speed display
Thanks for the reply!
Rounding 1.99999998 to a precision of 2 decimals for display would still end up with 2.0. So it seems to me that either no such rounding happens (just a simple truncation of the string), or the result here would be more like 2.3949999999 which seems surprisingly inaccurate?
Rounding 1.99999998 to a precision of 2 decimals for display would still end up with 2.0. So it seems to me that either no such rounding happens (just a simple truncation of the string), or the result here would be more like 2.3949999999 which seems surprisingly inaccurate?
Re: [2.0.43] Odd rounding effects in assembly machine crafting speed display
I agree this should be looked into, because I just put two Speed Module 1s into an Assembling Machine 2 making copper cable.
While the float representation of `4 * 0.75 * 1.4` does indeed come out to `4.199999999999999`, it gets rendered as `4.19` in-game. It is being truncated, not rounded.
While the float representation of `4 * 0.75 * 1.4` does indeed come out to `4.199999999999999`, it gets rendered as `4.19` in-game. It is being truncated, not rounded.
Re: [2.0.43] Odd rounding effects in assembly machine crafting speed display
There is no perfect answer for displaying fractional numbers as decimal strings. While you may think rounding is best: 0.04 rounded to 1 decimal place is 0 and will generate its own bug reports.
If you want to get ahold of me I'm almost always on Discord.
Re: [2.0.43] Odd rounding effects in assembly machine crafting speed display
Rounding out of output precision is one thing, but accounting for floating point being base-2 and giving one bit off is another - just add 1e-8 prior to rounding down (or round to nearest by adding 0.5 or 0.005). E.g "(std::stringstream() << std::fixed << std::setprecision(4) << 1.234567).str();"
Another thing on that - got today situation when rocket is 100% in silo, but "Launch" button says "it's not ready yet" (might be a bit misleading) when just a single crafting remained. For that kind of stuff it better be 0% when value is 0/M, 100% when value is strictly M/M. and everything else is clamped to 1%-99% range
Another thing on that - got today situation when rocket is 100% in silo, but "Launch" button says "it's not ready yet" (might be a bit misleading) when just a single crafting remained. For that kind of stuff it better be 0% when value is 0/M, 100% when value is strictly M/M. and everything else is clamped to 1%-99% range
-
Ralfinator
- Long Handed Inserter

- Posts: 73
- Joined: Sun Jun 26, 2016 9:37 pm
- Contact:
Re: [2.0.43] Odd rounding effects in assembly machine crafting speed display
0.04 truncated to 1 decimal place is also 0 (or rather, 0.0), so at least for this example, rounding vs truncation doesn't seem to make a difference.0.04 rounded to 1 decimal place is 0 and will generate its own bug reports


