Example usage for java.lang StrictMath log10

List of usage examples for java.lang StrictMath log10

Introduction

In this page you can find the example usage for java.lang StrictMath log10.

Prototype

public static native double log10(double a);

Source Link

Document

Returns the base 10 logarithm of a double value.

Usage

From source file:Main.java

public static void main(String[] args) {

    double d1 = 0.0, d2 = 1234.5, d3 = (1.0 / 0.0), d4 = 1;

    System.out.println("Log " + d1 + " with base 10 = " + StrictMath.log10(d1));

    System.out.println("Log " + d2 + " with base 10 = " + StrictMath.log10(d2));

    System.out.println("Log " + d3 + " with base 10 = " + StrictMath.log10(d3));

    System.out.println("Log " + d4 + " with base 10 = " + StrictMath.log10(d4));
}

From source file:Main.java

public static String formatValue(double value) {
    if (value > 0) {
        int power;
        String suffix = " kmbt";
        String formattedNumber = "";

        NumberFormat formatter = new DecimalFormat("#,###.#");
        power = (int) StrictMath.log10(value);
        value = value / (Math.pow(10, (power / 3) * 3));
        formattedNumber = formatter.format(value);
        formattedNumber = formattedNumber + suffix.charAt(power / 3);
        return formattedNumber.length() > 4 ? formattedNumber.replaceAll("\\.[0-9]+", "") : formattedNumber;
    } else {//from w  w w . ja v a 2s .c om
        return "0";
    }
}

From source file:net.nicoulaj.benchmarks.math.DoubleLog10.java

@GenerateMicroBenchmark
public void strictmath(BlackHole hole) {
    for (int i = 0; i < data.length - 1; i++)
        hole.consume(StrictMath.log10(data[i]));
}

From source file:edu.cornell.med.icb.goby.algorithmic.algorithm.dmr.ChiSquareTestAdaptor.java

@Override
public double calculateNoCovariate(int... a) {
    final int cma = a[0];
    final int ca = a[1];
    final int cmb = a[2];
    final int cb = a[3];

    if (cma == 0 || ca == 0 || cmb == 0 || cb == 0) {
        setIgnorePair(true);// w  ww.  ja va2  s .  com
        return -StrictMath.log10(1.0);
    }
    expectedCounts[0] = cma;
    expectedCounts[1] = ca;
    observedCounts[0] = cmb;
    observedCounts[1] = cb;
    double pValue = Double.NaN;
    final ChiSquareTest chisquare = new ChiSquareTestImpl();
    try {
        final double pValueRaw = chisquare.chiSquareTest(expectedCounts, observedCounts);
        // math commons can return negative p-values?
        pValue = Math.abs(pValueRaw);
    } catch (MaxIterationsExceededException e) {

        LOG.error("expected:" + DoubleArrayList.wrap(expectedCounts).toString());
        LOG.error("observed:" + LongArrayList.wrap(observedCounts).toString());
        LOG.error(e);
        pValue = 1.0;
        setIgnorePair(true);
    } catch (MathException e) {
        e.printStackTrace();
        setIgnorePair(true);

    }

    setIgnorePair(false);
    return -StrictMath.log10(pValue);
}

From source file:org.esa.beam.util.math.FastMathPerformance.java

public void testLog10() {
    System.gc();//from  ww  w  .  j a va  2  s .  c  o m
    double x = 0;
    long time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        x += StrictMath.log10(Math.PI + i/* 1.0 + i/1e9 */);
    long strictMath = System.nanoTime() - time;

    System.gc();
    double y = 0;
    time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        y += FastMath.log10(Math.PI + i/* 1.0 + i/1e9 */);
    long fastTime = System.nanoTime() - time;

    System.gc();
    double z = 0;
    time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        z += Math.log10(Math.PI + i/* 1.0 + i/1e9 */);
    long mathTime = System.nanoTime() - time;

    report("log10", x + y + z, strictMath, fastTime, mathTime);
}