1 | /* s_logbf.c -- float version of s_logb.c. |
2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. |
3 | */ |
4 | |
5 | /* |
6 | * ==================================================== |
7 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
8 | * |
9 | * Developed at SunPro, a Sun Microsystems, Inc. business. |
10 | * Permission to use, copy, modify, and distribute this |
11 | * software is freely granted, provided that this notice |
12 | * is preserved. |
13 | * ==================================================== |
14 | */ |
15 | |
16 | #include <math.h> |
17 | #include <math_private.h> |
18 | #include <libm-alias-float.h> |
19 | #include <fix-int-fp-convert-zero.h> |
20 | |
21 | float |
22 | __logbf (float x) |
23 | { |
24 | int32_t ix, rix; |
25 | |
26 | GET_FLOAT_WORD (ix, x); |
27 | ix &= 0x7fffffff; /* high |x| */ |
28 | if (ix == 0) |
29 | return (float) -1.0 / fabsf (x); |
30 | if (ix >= 0x7f800000) |
31 | return x * x; |
32 | if (__glibc_unlikely ((rix = ix >> 23) == 0)) |
33 | { |
34 | /* POSIX specifies that denormal number is treated as |
35 | though it were normalized. */ |
36 | rix -= __builtin_clz (ix) - 9; |
37 | } |
38 | if (FIX_INT_FP_CONVERT_ZERO && rix == 127) |
39 | return 0.0f; |
40 | return (float) (rix - 127); |
41 | } |
42 | libm_alias_float (__logb, logb) |
43 | |