[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: support for bitwise comparison of floats
From: |
Bruno Haible |
Subject: |
Re: support for bitwise comparison of floats |
Date: |
Sun, 25 Mar 2007 12:54:40 +0200 |
User-agent: |
KMail/1.5.4 |
Eric Blake wrote:
> You can also assume IEEE rules, and compare against signed infinity:
> 1 / +0. => +infinity
> 1 / -0. => -infinity
Nice trick :-)
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.
- On all processors, the caller could also have modified the FP exceptions
control mask, through the facilities declared in <fenv.h> or <ieeefp.h>
(FreeBSD, IRIX) or <fptrap.h> (AIX) or <fpxcp.h> (AIX). For this case,
we would need to deal with all possible CPU / OS / kernel combinations...
Bruno
Re: support for bitwise comparison of floats, Eric Blake, 2007/03/25
Re: support for bitwise comparison of floats, Paul Eggert, 2007/03/29