Web lists-archives.com

Re: [Mingw-users] msvcrt printf bug






Hi all,
Emanuel, thank you very much for stepping in. I am extremely happy that you found my code useful.
For me it's the first time that happens. You made the trouble of posting this issue worthwhile for me.
You can use the code however you like but beware I haven't tested for all possible inputs, as I need something to test against. Even the glibc printf starts dropping significant digits for denormals.
If I manage to test completely, I will notify you on your email.
My name is 'Alexandru', 'Andu' is a shorthand. No need to give me credit.
I started learning C by myself in 2010. I work in embedded, specifically digital power conversion and industrial control systems.
KH Man, thank you for your advice again. I am not a student, but I am still learning. I agree that this a non issue for most users. For me the matter is closed. I will use cygwin when I need a more accurate printf.



--
Securely sent with Tutanota. Claim your encrypted mailbox today!
https://tutanota.com

18. Jan 2017 05:39 by mingw-users-request@xxxxxxxxxxxxxxxxxxxxx:


Message: 1
Date: Wed, 18 Jan 2017 10:34:19 +0800
From: KHMan <keinhong@xxxxxxxxx>
Subject: Re: [Mingw-users] msvcrt printf bug
To: MinGW Users List <mingw-users@xxxxxxxxxxxxxxxxxxxxx>
Message-ID: <587ED42B.50000@xxxxxxxxx>
Content-Type: text/plain; charset=windows-1252; format=flowed

On 1/18/2017 6:27 AM, tei.andu@xxxxxxxxxxxx wrote:
[snip snip snip]
See:
http://stackoverflow.com/questions/3215235/how-do-you-print-the-exact-value-of-a-floating-point-number

The author stated:
"the number required to ?exactly print? its value"

This is flat out a monkey wrench that destroys the real-world
concept of a floating-point value.

He assumes pristine, exact values. This notion of pristine, exact
values disappears when you start doing calculations.

It's a magic kingdom, constrained to assumptions.

As for Emanuel's posting, I find it good for a chuckle. So the
binary representations were fine, and they spent years moping
about with ULP issues in ASCII representations. Look, some of us
would have fixed that in an afternoon. Enough said.

--
Cheers,
Kein-Hong Man (esq.)
Selangor, Malaysia




------------------------------

Message: 2
Date: Wed, 18 Jan 2017 03:44:28 +0100
From: Emanuel Falkenauer <E.Falkenauer@xxxxxxxxxxxxxxxxx>
Subject: Re: [Mingw-users] msvcrt printf bug
To: mingw-users@xxxxxxxxxxxxxxxxxxxxx
Message-ID: <73bc7dcb-f323-312a-07a1-01aa2d89fa67@xxxxxxxxxxxxxxxxx>
Content-Type: text/plain; charset=windows-1252; format=flowed

Hi KHMan,

Sorry, but you're WRONG: Tei's code is actually INVALUABLE to us (and
certainly not "Yawn"!!) - you'd be better off not berating him (or her?)
to be "a student" (why would "a student" be worse than you, btw?!) and
THINK about what (s)he has to say before making clearly wrong conclusions!

Emanuel

On 18-Jan-17 03:20, KHMan wrote:
On 1/18/2017 6:27 AM, tei.andu@xxxxxxxxxxxx wrote:
Hello all,
Thank you for your kind advice and your time. I also did some more
searching around.
I understand that there is no practicality to getting the exact
value of a float, only enough precision
that can give a back conversion (decimal string -> float) with the
same value is required.
However, my examples are correct. You can verify them with a
calculator with enough precision or a bignum library (or glibc).
If you google 'exact value of a float' you will even find code
samples that will do that. glibc also does it. The digits are not
garbage, they are the result of a complete conversion.
[snip snip]

Ultimately, you bear the risks. If you are still a student, be
humble, study more. Think before you cry wolf.
http://stackoverflow.com/questions/3215235/how-do-you-print-the-exact-value-of-a-floating-point-number
There is no rounding required if we want this exact value, no
floating point operations required,
[snip snip]

The blog post states there were ZERO errors doing round trips. No
errors. What bug?

Google may have smart people laser focused on the wrong things
too. Do not trust too easily.

So he wants to find perfection in ASCII displays of floats.
Yawn... Google and Google employees have money, leave them to play...

Once you do calculations in floating point, whatever 0.5ULP does
not matter anymore, error accumulates, the perfect ASCII display
is an exercise in perfectionism. Go and have fun with the
so-called perfect conversion code, however dubious its real-world
value is, but it's foolish to tell the world there are bugs here
and there. Think before you act, man.

IIRC you should not consider your kind of perfect ASCII conversion
to be of any real importance in real world settings. There was
once an article -- a grad student doing aerospace, his program was
so sensitive to tiny pertubations that he only got useful *cough*
'results' on a particular CPU. Other CPUs gave wildly different
results. After graduating, he questioned whether the program which
was supposed to produce consistently reproducible results was
actually useful if it amplified tiny variations in calculations
and made a molehill out of them. Was his research results good
valuable simulation or a molehill? Hmmm...

Error accumulates in real world calculations. Folks who enjoy
their perfect ASCII conversions should remain in their niche.

[snip snip]




------------------------------

Message: 3
Date: Wed, 18 Jan 2017 03:48:49 +0100
From: Emanuel Falkenauer <E.Falkenauer@xxxxxxxxxxxxxxxxx>
Subject: Re: [Mingw-users] msvcrt printf bug
To: mingw-users@xxxxxxxxxxxxxxxxxxxxx
Message-ID: <0f06d79b-fccf-bc40-8308-7e49ba8a43b2@xxxxxxxxxxxxxxxxx>
Content-Type: text/plain; charset=windows-1252; format=flowed

And btw: when will YOU become "humble" and start to "study more"? ;-)

On 18-Jan-17 03:44, Emanuel Falkenauer wrote:
Hi KHMan,

Sorry, but you're WRONG: Tei's code is actually INVALUABLE to us (and
certainly not "Yawn"!!) - you'd be better off not berating him (or
her?) to be "a student" (why would "a student" be worse than you,
btw?!) and THINK about what (s)he has to say before making clearly
wrong conclusions!

Emanuel

On 18-Jan-17 03:20, KHMan wrote:
On 1/18/2017 6:27 AM, tei.andu@xxxxxxxxxxxx wrote:
Hello all,
Thank you for your kind advice and your time. I also did some more
searching around.
I understand that there is no practicality to getting the exact
value of a float, only enough precision
that can give a back conversion (decimal string -> float) with the
same value is required.
However, my examples are correct. You can verify them with a
calculator with enough precision or a bignum library (or glibc).
If you google 'exact value of a float' you will even find code
samples that will do that. glibc also does it. The digits are not
garbage, they are the result of a complete conversion.
[snip snip]

Ultimately, you bear the risks. If you are still a student, be
humble, study more. Think before you cry wolf.
http://stackoverflow.com/questions/3215235/how-do-you-print-the-exact-value-of-a-floating-point-number

There is no rounding required if we want this exact value, no
floating point operations required,
[snip snip]

The blog post states there were ZERO errors doing round trips. No
errors. What bug?

Google may have smart people laser focused on the wrong things
too. Do not trust too easily.

So he wants to find perfection in ASCII displays of floats.
Yawn... Google and Google employees have money, leave them to play...

Once you do calculations in floating point, whatever 0.5ULP does
not matter anymore, error accumulates, the perfect ASCII display
is an exercise in perfectionism. Go and have fun with the
so-called perfect conversion code, however dubious its real-world
value is, but it's foolish to tell the world there are bugs here
and there. Think before you act, man.

IIRC you should not consider your kind of perfect ASCII conversion
to be of any real importance in real world settings. There was
once an article -- a grad student doing aerospace, his program was
so sensitive to tiny pertubations that he only got useful *cough*
'results' on a particular CPU. Other CPUs gave wildly different
results. After graduating, he questioned whether the program which
was supposed to produce consistently reproducible results was
actually useful if it amplified tiny variations in calculations
and made a molehill out of them. Was his research results good
valuable simulation or a molehill? Hmmm...

Error accumulates in real world calculations. Folks who enjoy
their perfect ASCII conversions should remain in their niche.

[snip snip]





------------------------------

Message: 4
Date: Wed, 18 Jan 2017 11:04:47 +0800
From: KHMan <keinhong@xxxxxxxxx>
Subject: Re: [Mingw-users] msvcrt printf bug
To: MinGW Users List <mingw-users@xxxxxxxxxxxxxxxxxxxxx>
Message-ID: <587EDB4F.2050705@xxxxxxxxx>
Content-Type: text/plain; charset=windows-1252; format=flowed

On 1/18/2017 10:44 AM, Emanuel Falkenauer wrote:
Hi KHMan,

Sorry, but you're WRONG: Tei's code is actually INVALUABLE to us (and
certainly not "Yawn"!!) - you'd be better off not berating him (or her?)
to be "a student" (why would "a student" be worse than you, btw?!) and
THINK about what (s)he has to say before making clearly wrong conclusions!

Oh, so sorry for making you angry. I apologize, I apologize. Cheer
up :-)

I have always prefaced the gently-prodding student thing with
"If". Check back if you think otherwise. I presumed Tei did not
want to divulge any information of that sort. I think "berating"
is a wrong characterization, now it's you who is doing that to me.

Bruce Dawson's work is interesting, but some of the talk may be
misleading to some folks. So he wants consistent ASCII
representations, good for multi-platform work. float was fine for
round trip, at the end he stated that VC++ double conversion may
have issues. Interesting, but too many uses of 'exact' that makes
me cringe.

I thought everyone knew not to rely on exact ASCII representations
across everywhere. Isn't it obvious from an engineering
standpoint? Floating point is a lot about managing imperfection...

--
Cheers,
Kein-Hong Man (esq.)
Selangor, Malaysia




------------------------------

Message: 5
Date: Wed, 18 Jan 2017 04:39:13 +0100
From: Emanuel Falkenauer <E.Falkenauer@xxxxxxxxxxxxxxxxx>
Subject: Re: [Mingw-users] msvcrt printf bug
To: mingw-users@xxxxxxxxxxxxxxxxxxxxx
Message-ID: <8513cf4b-261b-6e43-dec7-2e02f9aa163a@xxxxxxxxxxxxxxxxx>
Content-Type: text/plain; charset=windows-1252; format=flowed

Hi KHMan,

Ok, apologies accepted! Above all, I hope Tei feels better... :-)

I've been long enough in HPC to know that floats are of course not ideal
- but when you need to allocate dozens of Gigs of data to hold info for
dozens of threads running at the same time, they do become extremely
valuable as an alternative to doubles (not to mention long doubles)
because of their modest size.
But printing them has always been a pain in the neck - of course I
figured out already in the 80-ties that you can print their binary
contents instead, but it's really horrendously time consuming to then
try to figure out "Oh my, is 0x0EA478A9 bigger or smaller than whatever
in float?" Tei's code solves that problem for me once for all and across
compilers, and I'm sure grateful for that help.

As I said: issue settled, no hard feelings left. Have a great day!

Emanuel

On 18-Jan-17 04:04, KHMan wrote:
On 1/18/2017 10:44 AM, Emanuel Falkenauer wrote:
Hi KHMan,

Sorry, but you're WRONG: Tei's code is actually INVALUABLE to us (and
certainly not "Yawn"!!) - you'd be better off not berating him (or her?)
to be "a student" (why would "a student" be worse than you, btw?!) and
THINK about what (s)he has to say before making clearly wrong conclusions!
Oh, so sorry for making you angry. I apologize, I apologize. Cheer
up :-)

I have always prefaced the gently-prodding student thing with
"If". Check back if you think otherwise. I presumed Tei did not
want to divulge any information of that sort. I think "berating"
is a wrong characterization, now it's you who is doing that to me.

Bruce Dawson's work is interesting, but some of the talk may be
misleading to some folks. So he wants consistent ASCII
representations, good for multi-platform work. float was fine for
round trip, at the end he stated that VC++ double conversion may
have issues. Interesting, but too many uses of 'exact' that makes
me cringe.

I thought everyone knew not to rely on exact ASCII representations
across everywhere. Isn't it obvious from an engineering
standpoint? Floating point is a lot about managing imperfection...




------------------------------

------------------------------------------------------------------------------
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
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users


End of MinGW-users Digest, Vol 128, Issue 9
*******************************************
------------------------------------------------------------------------------
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
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
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:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe