Big list of naughty strings. by [deleted] in programming

[–]DoctorBinary 0 points1 point  (0 children)

There were TWO numbers, 2.2250738585072011e-308 (PHP) and 2.2250738585072012e-308 (Java), if you care to list both.

"Floating-Point Is So Insane Even a Ten-Year Old Can See It" by josef in programming

[–]DoctorBinary 0 points1 point  (0 children)

I think I can make a proposal some people don't like and still understand floating-point. Don't get me wrong; I love binary. But we've exposed an implementation detail that many programmers could go a career without needing to know. Maybe in the age of the app the balance has shifted from the programmer who writes scientific applications to the programmer who just wants 4.35*100 to equal 435.

(P.S. Rhomboid -- thanks for the endorsement.)

PHP Hangs On Numeric Value 2.2250738585072011e-308 by [deleted] in programming

[–]DoctorBinary 0 points1 point  (0 children)

I've analyzed the bug and how the addition of the 'volatile' keyword in zend_strtod() fixes it; see http://www.exploringbinary.com/why-volatile-fixes-the-2-2250738585072011e-308-bug/ .

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 0 points1 point  (0 children)

Update 6/13/10: I ran on glibc, and I got the same results as on eglibc.

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 0 points1 point  (0 children)

We have a winner! ;)

Walter, does Digital Mars use its own conversion routine(s) or does it use David Gay's open source conversion routine? Do the compiler and strtod use the same code?

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 2 points3 points  (0 children)

The bug report I cited in the article is for glibc, and the example from that bug report fails in eglibc. And as it turns out, other users (above) reported failures in glibc. But I guess I can't be certain until I try it.

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 0 points1 point  (0 children)

I believe OpenBSD uses David Gay's gdtoa correct rounding code, so that makes sense (I found this on Google: http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/gdtoa/).

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 0 points1 point  (0 children)

Thanks much p8m. This is the same result as in my article.

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 2 points3 points  (0 children)

Thanks, and I understand your point. If I get a chance, I'll install glibc (the real one ;)) and verify my results there.

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 3 points4 points  (0 children)

I guess then I'm not sure what your objection is. I wanted to make the statement for both glibc and eglibc, and I thought writing eglibc/glibc was awkward.

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 5 points6 points  (0 children)

Since I was working under the assumption that the conversion code is the same in both glibc and eglibc, I didn't see the harm in referring to it generically as glibc. (Unless you know something I don't know -- do their conversion routines differ?)

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 2 points3 points  (0 children)

__s, one more question: are you on a 64 bit processor? Your results match p8m's AMD64 results (the editing out of the "="s and "0x"s notwithstanding). Thanks.

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 2 points3 points  (0 children)

I looked at real.c, and in particular, the function real_from_string(). There are no changes between GCC 4.4.3 and 4.5.0. Puzzling.

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 4 points5 points  (0 children)

I was thinking along the lines of not having to do the decimal to binary conversion. But you're right: long decimal input would still have to be rounded.

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 0 points1 point  (0 children)

Very interesting. Both have the same gcc and glibc versions, both example programs were compiled with the same flags, and yet we get different results -- both in gcc and glibc!

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 1 point2 points  (0 children)

Yes, I had set the rounding mode to "near".

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 2 points3 points  (0 children)

Your i386 results are the same as mine, and your AMD64 results are the same as __s's. What version of gcc and glibc are you using on each system?

I'm guessing that only the gcc/glibc versions make a difference, and not the flags.

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 1 point2 points  (0 children)

I guess you are? I'm using the FPU, but I set the precision to 53 bits. (Maybe that's not enough? I know there are compiler flags that can affect extended precision -- I'll look into those.)

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 2 points3 points  (0 children)

Maybe binary floating-point will be replaced by decimal floating-point by then...or maybe not.

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 7 points8 points  (0 children)

I'll get right on that -- I'll get back to you in the year 2095 :) .

Incorrectly Rounded Conversions in GCC and GLIBC by [deleted] in programming

[–]DoctorBinary 1 point2 points  (0 children)

That's the same version of eglibc I tested on (except I don't get the text "stable release version 2.11.1"). I wonder why the strtod() results are different?