This source file includes following definitions.
- log2l
- log2l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include <config.h>
18
19
20 #include <math.h>
21
22 #if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
23
24 long double
25 log2l (long double x)
26 {
27 return log2 (x);
28 }
29
30 #else
31
32
33 #define LOG2 0.693147180559945309417232121458176568075L
34
35
36 #define LOG2_INVERSE 1.44269504088896340735992468100189213743L
37
38
39 #define SQRT_HALF 0.707106781186547524400844362104849039284L
40
41 long double
42 log2l (long double x)
43 {
44 if (isnanl (x))
45 return x;
46
47 if (x <= 0.0L)
48 {
49 if (x == 0.0L)
50
51 return - HUGE_VALL;
52 else
53 {
54
55 #if (defined _MSC_VER && !defined __clang__) || (defined __sgi && !defined __GNUC__)
56 static long double zero;
57 return zero / zero;
58 #else
59 return 0.0L / 0.0L;
60 #endif
61 }
62 }
63
64
65
66
67
68
69
70 {
71 int e;
72 long double y;
73
74 y = frexpl (x, &e);
75 if (y < SQRT_HALF)
76 {
77 y = 2.0L * y;
78 e = e - 1;
79 }
80
81 return (long double) e + logl (y) * LOG2_INVERSE;
82 }
83 }
84
85 #endif