Example usage for java.lang StrictMath expm1

List of usage examples for java.lang StrictMath expm1

Introduction

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

Prototype

public static native double expm1(double x);

Source Link

Document

Returns ex -1.

Usage

From source file:Main.java

public static void main(String[] args) {

    double d1 = 0.0, d2 = -(1.0 / 0.0), d3 = (1.0 / 0.0);

    System.out.println(StrictMath.expm1(d1));

    System.out.println(StrictMath.expm1(d2));

    System.out.println(StrictMath.expm1(d3));
}

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

public void testExpm1() {
    System.gc();/*from w w w  .  j a  v  a2 s.  c o m*/
    double x = 0;
    long time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        x += StrictMath.expm1(-i * F1);
    long strictTime = System.nanoTime() - time;

    System.gc();
    double y = 0;
    time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        y += FastMath.expm1(-i * F1);
    long fastTime = System.nanoTime() - time;

    System.gc();
    double z = 0;
    time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        z += Math.expm1(-i * F1);
    long mathTime = System.nanoTime() - time;
    report("expm1", x + y + z, strictTime, fastTime, mathTime);
}