123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #include "math.h"
- #include "math_private.h"
- int ilogb(double x)
- {
- int32_t hx,lx,ix;
- GET_HIGH_WORD(hx, x);
- hx &= 0x7fffffff;
- if (hx < 0x00100000) {
- GET_LOW_WORD(lx, x);
- if ((hx|lx)==0)
- return FP_ILOGB0;
-
- ix = -1043;
- if (hx != 0) {
- ix = -1022;
- lx = (hx << 11);
- }
-
- for (; lx > 0; lx <<= 1)
- ix--;
- return ix;
- }
- if (hx < 0x7ff00000)
- return (hx>>20) - 1023;
- if (FP_ILOGBNAN != (~0U >> 1)) {
- GET_LOW_WORD(lx, x);
- if (hx == 0x7ff00000 && lx == 0)
- return ~0U >> 1;
- }
-
- return FP_ILOGBNAN;
- }
- libm_hidden_def(ilogb)
|