Floating point math problems
Posted: Wed Mar 04, 2020 7:10 pm
I've played enough sandbox to identify a couple times when 100 does not equal 100. Where 100 turns to 99.9 and you cannot obtain the last 1% I'm almost convinced it's due to rounding issues. I'm going to take fluid in pipes as my first example. The offshore pump doesn't push 999.9/s. Oil refineries don't produce 44.9 Petroleum Gas. Lubricant doesn't produce 19.9. But, as soon as any fluid enters a pipe, 0.1 fluid is lost and can't be made up. Perfect building to building connection (boiler -> steam engine -> steam engine) won't lose any of the fluid. Pipes shouldn't have a floating point for it's volume. Tanks shouldn't either. Make it a whole integer. The only thing that outputs floating points that I can recall are pumpjacks for crude oil. So, change it to a fixed INT (FLOOR() it's value: 16.8 = 16, 16.1 = 16, 0.9 = 0).
Second issue - also think it's related to floating points but not sure. Reproducable. Any science pack (let's start with just red Automation) while being consumed in a lab when power browns out (yellow or red energy bar), but not a blackout (zero energy). will consume 1% of the science pack so the research tech you've made 10 packs for 10 required will take 11 packs to complete with 99% left over of #11.
Yea, I'm nitpicking details. I want my 1%!
TY for reading. Hope to see this addressed.
Second issue - also think it's related to floating points but not sure. Reproducable. Any science pack (let's start with just red Automation) while being consumed in a lab when power browns out (yellow or red energy bar), but not a blackout (zero energy). will consume 1% of the science pack so the research tech you've made 10 packs for 10 required will take 11 packs to complete with 99% left over of #11.
Yea, I'm nitpicking details. I want my 1%!
TY for reading. Hope to see this addressed.