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