1 /* @(#)s_logb.c 5.1 93/09/24 */
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
10 * ====================================================
15 * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
20 #include <math_private.h>
27 EXTRACT_WORDS (ix
, lx
, x
);
28 ix
&= 0x7fffffff; /* high |x| */
30 return -1.0 / fabs (x
);
33 if (__builtin_expect ((rix
= ix
>> 20) == 0, 0))
35 /* POSIX specifies that denormal number is treated as
36 though it were normalized. */
37 int m1
= (ix
== 0) ? 0 : __builtin_clz (ix
);
38 int m2
= (lx
== 0) ? 0 : __builtin_clz (lx
);
39 int ma
= (m1
== 0) ? m2
+ 32 : m1
;
40 return -1022.0 + (double)(11 - ma
);
42 return (double) (rix
- 1023);
44 weak_alias (__logb
, logb
)
46 strong_alias (__logb
, __logbl
) weak_alias (__logb
, logbl
)