From 98c9af500125df41fdb46d7e384b00982d72493a Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 5 May 2012 22:22:46 -0400 Subject: fix definitions of FP_ILOGB constants two issues: (1) the type was wrong (unsigned instead of signed int), and (2) the value of FP_ILOGBNAN should be INT_MIN rather than INT_MAX to match the ABI. this is also much more useful since INT_MAX corresponds to a valid input (infinity). the standard would allow us to set FP_ILOGB0 to -INT_MAX instead of INT_MIN, which would give us distinct values for ilogb(0) and ilogb(NAN), but the benefit seems way too small to justify ignoring the ABI. note that the macro is just a "portable" (to any twos complement system where signed and unsigned int have the same width) way to write INT_MIN without needing limits.h. it's valid to use this method since these macros are not required to work in #if directives. --- include/math.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/math.h') diff --git a/include/math.h b/include/math.h index d4359f32..61738e6a 100644 --- a/include/math.h +++ b/include/math.h @@ -28,8 +28,8 @@ extern "C" { #define MATH_ERREXCEPT 2 #define math_errhandling 2 -#define FP_ILOGBNAN (((unsigned)-1)>>1) -#define FP_ILOGB0 (~FP_ILOGBNAN) +#define FP_ILOGBNAN (-1-(int)(((unsigned)-1)>>1)) +#define FP_ILOGB0 FP_ILOGBNAN #define FP_NAN 0 #define FP_INFINITE 1 -- cgit v1.2.1