Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/lib/libm/src/s_ilogbf.c,v rcsdiff: /ftp/cvs/cvsroot/src/lib/libm/src/s_ilogbf.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.8 retrieving revision 1.9 diff -u -p -r1.8 -r1.9 --- src/lib/libm/src/s_ilogbf.c 2013/02/09 22:56:00 1.8 +++ src/lib/libm/src/s_ilogbf.c 2016/08/24 10:03:32 1.9 @@ -15,26 +15,33 @@ #include #if defined(LIBM_SCCS) && !defined(lint) -__RCSID("$NetBSD: s_ilogbf.c,v 1.8 2013/02/09 22:56:00 matt Exp $"); +__RCSID("$NetBSD: s_ilogbf.c,v 1.9 2016/08/24 10:03:32 christos Exp $"); #endif -#include "math.h" +#include +#include #include "math_private.h" int ilogbf(float x) { - int32_t hx,ix; + int32_t hx, ix; - GET_FLOAT_WORD(hx,x); + GET_FLOAT_WORD(hx, x); hx &= 0x7fffffff; - if(hx<0x00800000) { - if(hx==0) - return FP_ILOGB0; /* ilogb(0) = 0x80000001 */ - else /* subnormal x */ - for (ix = -126,hx<<=8; hx>0; hx<<=1) ix -=1; - return ix; + if (hx < 0x00800000) { + if (hx == 0) { + feraiseexcept(FE_INVALID); + return FP_ILOGB0; /* ilogb(0) = 0x80000001 */ + } + for (ix = -126, hx <<= 8; hx > 0; hx <<= 1) ix -= 1; + return ix; } - else if (hx<0x7f800000) return (hx>>23)-127; - else return FP_ILOGBNAN; /* inf too */ + + if (hx < 0x7f800000) { + return (hx >> 23) - 127; + } + + feraiseexcept(FE_INVALID); + return isnan(x) ? FP_ILOGBNAN : INT_MAX; }