2 * ====================================================
3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 * Developed at SunPro, a Sun Microsystems, Inc. business.
6 * Permission to use, copy, modify, and distribute this
7 * software is freely granted, provided that this notice
9 * ====================================================
13 * return the binary exponent of non-zero x
14 * ilogb(0) = FP_ILOGB0
15 * ilogb(NaN) = FP_ILOGBNAN (no signal is raised)
16 * ilogb(inf) = INT_MAX (no signal is raised)
22 #include "math_private.h"
28 EXTRACT_WORDS(hx,lx,x);
33 else /* subnormal x */
35 for (ix = -1043; lx>0; lx<<=1) ix -=1;
37 for (ix = -1022,hx<<=11; hx>0; hx<<=1) ix -=1;
41 else if (hx<0x7ff00000) return (hx>>20)-1023;
42 else if (hx>0x7ff00000 || lx!=0) return FP_ILOGBNAN;