Re: [Mingw-users] msvcrt printf bug
-----BEGIN PGP SIGNED MESSAGE-----
On 18/01/17 23:34, Emanuel Falkenauer wrote:
> Trouble is, it's NOT trivial to stop before that limit with printf.
> Sure, I could print %.2f when the two digits are the only valid ones,
> but that would prevent me from correctly printing e.g. 0.00001234 so
> that it would show differently from 0.00001236 (even though both
> only have four significant digits). I simply didn't find a reliable
> way of printing those floats when they vary by orders of magnitude.
"%.2f" doesn't specify significant digits -- it specifies digits
after the radix point. If you want to see, and compare, just so
many significant digits, you would surely be better off using
"%.2e", (so you don't get the leading insignificant zeros).
One other potential issue, which I neglected to mention: when you
perform floating point calculations you may suffer rounding, or
even cancellation effects, all of which conspire to make even less
than the absolute maximum representable precision available. This
may be further compounded by differing FPU configuration between
implementations -- e.g. it is my understanding that Microsoft
configure the FPU to operate in 8-byte register mode, whereas
GCC uses full 10-byte capability. Such configuration differences
could lead to rounding differences, even within the available
53-binary/15.955-decimal digit precision limit.
> I would LOVE to use _your_ printf... but remember: the whole story is
> about comparing with Borland builds, where it's not available.
Well, you are always likely to be on a hiding to nothing, when
you compare apples with oranges, and expect identity -- in this
case, how can you possibly expect consistency between Borland's
proprietary (likely undisclosed) algorithm and A. N. Other's?
If you want guaranteed consistency, you'd better use identically
the same algorithm; what's to stop you compiling, and using, our printf() in your Borland builds, in place of their proprietary
Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (GNU/Linux)
-----END PGP SIGNATURE-----
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
MinGW-users mailing list
This list observes the Etiquette found at
We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated.
You may change your MinGW Account Options or unsubscribe at: