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) = 0x80000001
15 * ilogb(inf/NaN) = 0x7fffffff (no signal is raised)
19 #include "math_private.h"
30 return 0x80000001; /* ilogb(0) = 0x80000001 */
31 else /* subnormal x */
33 for (ix = -1043; lx>0; lx<<=1) ix -=1;
35 for (ix = -1022,hx<<=11; hx>0; hx<<=1) ix -=1;
39 else if (hx<0x7ff00000) return (hx>>20)-1023;
40 else return 0x7fffffff;
42 libm_hidden_def(ilogb)