Version 0.16.32

Information about releases and roadmap.
ratchetfreak
Filter Inserter
Filter Inserter
Posts: 950
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Version 0.16.32

Post by ratchetfreak »

mrvn wrote:
golfmiketango wrote:
mrvn wrote:Also there is a standard for floating point numbers that dictate strict rounding rules and allow you to convert to decimal and back without any loss of precision. You just have to do it right and not simply cut of floats after 5 digits.
Is there? I don't know if factorio really uses bare C++ floating point types (and kinda doubt it), but either way, I'm sure it's easy to come close, but hard to truly nail this. And presumably, factorio needs (or at least wants) to really nail this, to avoid desyncs.

Cross-platform architecture-variant-independent round-trippable floating-point pretty-printing is hard AF to implement perfectly. Not saying it's an insurmountable problem, just wonder if maybe you're not quite aware of what a profound clusterfuck floats are in x86. I could easily see it taking a competent-man-month, or something in that ballpark (0.999999999999999999999999999999997 x 10⁰ competent-man-months? :lol:), and a non-negligible hardware budget, to nail down 100% perfectly.

That stated, some liberally-licensed prior art surely exists, somewhere, from which the really tricky bits could be stolen.
It's actually quite trivial to implement. All it takes is to tell the compiler to use strict ieee floating point math and the right format string when printing them. The downside is that strict float behaviour disables a bunch of optimizations and has to constantly fix the x86s extra precision. So you would loose ups. On the plus side though you would gain cross architecture compatibility. E.g. if fatorio ever is ported to arm or powerpc or such then that becomes essential.

Personally where I needed to save/load floats in my microkernel for an RaspberryPI (no ieee conform printf()/scanf() for floats) I've decided to print them out in hexadezimal notation. That way you can print the exact bit pattern of the mantisse without the base 10 throwing in rounding errors. Neatly avoids the whole issue. E.g. 0x13a173E+1a. Saddly there is no standard for that.
There is a standard for hex flaot literals: 0x1.13A173Ep26 instead of e you use p to separate the exponent and the exponent is in base 10

mrvn
Smart Inserter
Smart Inserter
Posts: 5682
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Version 0.16.32

Post by mrvn »

ratchetfreak wrote:
mrvn wrote: Personally where I needed to save/load floats in my microkernel for an RaspberryPI (no ieee conform printf()/scanf() for floats) I've decided to print them out in hexadezimal notation. That way you can print the exact bit pattern of the mantisse without the base 10 throwing in rounding errors. Neatly avoids the whole issue. E.g. 0x13a173E+1a. Saddly there is no standard for that.
There is a standard for hex flaot literals: 0x1.13A173Ep26 instead of e you use p to separate the exponent and the exponent is in base 10
I stand corrected. It's actually supported in GNU printf. How did I miss that.

Code: Select all

% printf "%f %s\n" "0x1.13A173Ep26" "0x1.13A173Ep26"
72254927.500000 0x1.13A173Ep26

Post Reply

Return to “Releases”