bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: support for bitwise comparison of floats


From: Eric Blake
Subject: Re: support for bitwise comparison of floats
Date: Sun, 25 Mar 2007 08:00:47 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.10) Gecko/20070221 Thunderbird/1.5.0.10 Mnenhy/0.7.4.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Bruno Haible on 3/25/2007 4:54 AM:
> Eric Blake wrote:
>> You can also assume IEEE rules, and compare against signed infinity:
>> 1 / +0. => +infinity
>> 1 / -0. => -infinity
> 
> Nice trick :-)

Thanks for correcting my typo; which I realized after I sent my other
message. :)

> 
> But here you depend on the IEEE rules for exceptions upon division by zero.
>   - On Alpha processors, division by zero (and even overflow!) leads to a 
> SIGFPE
>     signal by default. And it requires the use of a system call to change
>     the FP exceptions control mask (the <fenv.h> routines in glibc >= 2.1,
>     the __setfpucw function in glibc 2.0). memcmp is certainly much cheaper.

Raw operations on bits is much faster than actual floating point in a
number of cases; as you have noted, the problem is the portability in
detecting where the raw bits are.  Your method appears fine to me.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGBoBe84KuGfSFAYARAqLNAJ4tA6sWiQhBHpuCW99z55TcvPEvDgCfXOKB
519nbAi5YgVMyMX8AuaRyvI=
=IMUI
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]