MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / log2_c11

Method log2_c11

JSAT/src/jsat/math/FastMath.java:101–110  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

testLog2_c11Method · 0.95

Calls 2

getMantissaMethod · 0.95
getExponentMethod · 0.45

Tested by 1

testLog2_c11Method · 0.76