Where's the Cross-Platform -0.0 Knowledge?

by chromatic

If you look at the CPAN test reports for Parrot, you'll see that the pernicious and persistent problems relate to odd bits of not-quite-always-cross-platform math, specifically floating point numbers and not-a-numbers.

It's reasonably easy to find and read the C89 and POSIX specifications. They're well-published. Even if there are confusing parts and contradictions, you can look for them and find the specifications.

Now try to find current information about how various operating systems and the various compilers and major versions and minor versions and libc versions in all of those combinations interact. In short, if I want to figure out exactly what OpenBSD does in its C library in its standard configuration to return a negative floating point 0.0 (or not, as the case may be), where do I go, what do I read, who do I talk to, and -- most importantly -- how do I change the software I work on to deal with those platform-specific quirks such that the users of my software don't even have to know that these quirks exist? Ditto GNU/Linux, Cygwin, FreeBSD, Mac OS X, et cetera.

I know that knowledge exists somewhere. Perl 5's core encodes it somewhere. I suspect the same is true of Python and Emacs and Guile and Glib and kde-base or related projects. Yet the knowledge in code is only useful in two ways. First, in projects that use the code directly and only need to trust that it does the right thing. Second, if other people read the code.

There ought to be a third option: encapsulating that knowledge outside of code somewhere. Maybe this specific case is documented and I just can't find it. The same goes for alignment concerns (64-bit Intel/AMD, PA-Risc, Sparc, ARM), pointer sizes, and other information.

Does this information exist in one or two good places, or does everyone have to track it down on his or her own? Worse, does everyone just hope these problems never come up?


2008-04-16 11:04:24
I sure hope someone out there knows a good solution for this. In the past I have given up and just created different conditions for different operating systems and used autotools to try and figure things out. This lead to headaches and I never found an elegant solution.
A few people pointed me to look at perl5's numeric.c which sadly I could not figure out if I was even looking at the right thing ;P