R.Wieser
2019-08-08 11:52:31 UTC
Hello all,
I've been caught out a few times by an unexpected long result while printing
a float into a buffer using a "sprintf" function (several available, in (at
least) five different DLLs).
So, I did a google to determine the absolute maximum-to-be-expected size of
the outputted string, and found this:
https://www.exploringbinary.com/maximum-number-of-decimal-digits-in-binary-floating-point-numbers/
But even the size for a simple 8 byte float (standard under Windows) is a
whopping 309 chars.
Hence my question: Is there a method/function which limits the outputted
length ? Something that will use the scientific "E" notation will do
fine.
Regards,
Rudy Wieser
I've been caught out a few times by an unexpected long result while printing
a float into a buffer using a "sprintf" function (several available, in (at
least) five different DLLs).
So, I did a google to determine the absolute maximum-to-be-expected size of
the outputted string, and found this:
https://www.exploringbinary.com/maximum-number-of-decimal-digits-in-binary-floating-point-numbers/
But even the size for a simple 8 byte float (standard under Windows) is a
whopping 309 chars.
Hence my question: Is there a method/function which limits the outputted
length ? Something that will use the scientific "E" notation will do
fine.
Regards,
Rudy Wieser