Page 1 of 1

Fractional/rounding glitches?

Posted: Wed Nov 08, 2017 10:55 am
by dracosilv
I don't know if this is a bug in factorio or not.. or if its in the mods I'm using or not.. but I've sometimes had it where pipes don't seem to fully empty.. (they register 0.0 fluid in them) and then tanks or other machines seem to have slightly less than round-numbers of materials in them..

Is this a glitch of the mods? (I'm playing seablock) or is it something inherent to the system? (I swear I've seen it happen in vanilla factorio with oil/oil-products as well)

Sorry if this is the wrong location for this thread, its my first post and I'm unsure exactly where to post it...
Seablock1.png
Seablock1.png (2.08 MiB) Viewed 1370 times
Seablock2.png
Seablock2.png (1.94 MiB) Viewed 1370 times

Re: Fractional/rounding glitches?

Posted: Wed Nov 08, 2017 11:53 am
by Rseding91
It's simply how floating point numbers work in computers: it's not possible to represent every real number in binary format because it doesn't have infinite precision.

For example: 1/3rd can't be stored in a single value because it's technically infinite: 0.3333333333333~ forever.

Re: Fractional/rounding glitches?

Posted: Wed Nov 08, 2017 1:16 pm
by sillyfly
More precisely - if its binary representation isn't finite.
For example, 1/5 = 0.2, which has a finite representation in base 10. However, in base 2 it is 0.00110011..., so it can still not be represented accurately in a binary floating point number (=the sane way computers handle non-integers)