@Test public void testApproxLog() { double x = 1e-6; for (int i = 0; i < 1000; i++) { assertEquals(Math.log(x) / Math.log(2), LogHistogram.approxLog2(x), 0.01); x *= 1.0 + Math.PI / 100.0; } assertTrue("Insufficient range", x > 1e6); }
@SuppressWarnings("WeakerAccess") public static double approxLog2(double value) { final long valueBits = Double.doubleToRawLongBits(value); final long exponent = ((valueBits & 0x7ff0_0000_0000_0000L) >>> 52) - 1024; final double m = Double.longBitsToDouble((valueBits & 0x800fffffffffffffL) | 0x3ff0000000000000L); return (m * (2 - (1.0 / 3) * m) + exponent - (2.0 / 3.0)); }
LogHistogram extends Histogram { @SuppressWarnings("WeakerAccess") public static double approxLog2(double value) { final long valueBits = Double.doubleToRawLongBits(value); final long exponent = ((valueBits & 0x7ff0_0000_0000_0000L) >>> 52) - 1024; final double m = Double.longBitsToDouble((valueBits & 0x800fffffffffffffL) | 0x3ff0000000000000L); return (m * (2 - (1.0 / 3) * m) + exponent - (2.0 / 3.0)); } }
LogHistogram extends Histogram { @SuppressWarnings("WeakerAccess") public static double approxLog2(double value) { final long valueBits = Double.doubleToRawLongBits(value); final long exponent = ((valueBits & 0x7ff0_0000_0000_0000L) >>> 52) - 1024; final double m = Double.longBitsToDouble((valueBits & 0x800fffffffffffffL) | 0x3ff0000000000000L); return (m * (2 - (1.0 / 3) * m) + exponent - (2.0 / 3.0)); } @SuppressWarnings("WeakerAccess")  LogHistogram(double min, double max); @SuppressWarnings("WeakerAccess")  LogHistogram(double min, double max, double epsilonFactor); }
LogHistogram extends Histogram { @SuppressWarnings("WeakerAccess") public static double approxLog2(double value) { final long valueBits = Double.doubleToRawLongBits(value); final long exponent = ((valueBits & 0x7ff0_0000_0000_0000L) >>> 52) - 1024; final double m = Double.longBitsToDouble((valueBits & 0x800fffffffffffffL) | 0x3ff0000000000000L); return (m * (2 - (1.0 / 3) * m) + exponent - (2.0 / 3.0)); } @SuppressWarnings("WeakerAccess")  LogHistogram(double min, double max); @SuppressWarnings("WeakerAccess")  LogHistogram(double min, double max, double epsilonFactor); @SuppressWarnings("WeakerAccess") static double approxLog2(double value); @SuppressWarnings("WeakerAccess") static double pow2(double x); }
LogHistogram extends Histogram { @SuppressWarnings("WeakerAccess") public static double approxLog2(double value) { final long valueBits = Double.doubleToRawLongBits(value); final long exponent = ((valueBits & 0x7ff0_0000_0000_0000L) >>> 52) - 1024; final double m = Double.longBitsToDouble((valueBits & 0x800fffffffffffffL) | 0x3ff0000000000000L); return (m * (2 - (1.0 / 3) * m) + exponent - (2.0 / 3.0)); } @SuppressWarnings("WeakerAccess")  LogHistogram(double min, double max); @SuppressWarnings("WeakerAccess")  LogHistogram(double min, double max, double epsilonFactor); @SuppressWarnings("WeakerAccess") static double approxLog2(double value); @SuppressWarnings("WeakerAccess") static double pow2(double x);  }