Computes log 2 (x) using a cache of 2 11 values, consuming approximately 17 kilobytes of memory. The results are generally accurate to an absolute and relative error of 10 -4 @param x the input @return the log base 2 of x
(double x)
| 99 | * @return the log base 2 of {@code x} |
| 100 | */ |
| 101 | public static double log2_c11(double x) |
| 102 | { |
| 103 | if(x < 0) |
| 104 | return Double.NaN; |
| 105 | long rawBits = doubleToLongBits(x); |
| 106 | long mantissa = getMantissa(rawBits); |
| 107 | int e = Math.getExponent(x); |
| 108 | |
| 109 | return log2Cache11[(int)(mantissa >>> (52-11))] + e; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Computes 2<sup>x</sup> exactly be exploiting the IEEE format |