Example usage for java.lang Math pow

List of usage examples for java.lang Math pow

Introduction

In this page you can find the example usage for java.lang Math pow.

Prototype

@HotSpotIntrinsicCandidate
public static double pow(double a, double b) 

Source Link

Document

Returns the value of the first argument raised to the power of the second argument.

Usage

From source file:Main.java

public static Double roundDouble(double val, int precision) {
    Double ret = null;//w  w  w. ja  v  a  2  s  . c  om
    try {
        double factor = Math.pow(10, precision);
        ret = Math.floor(val * factor + 0.5) / factor;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return ret;
}

From source file:Main.java

public static double calcularHipotenusa(double catetoA, double catetoB) {
    //TODO suponemos valores correctos

    return Math.sqrt(Math.pow(catetoA, 2) + Math.pow(catetoB, 2));
}

From source file:Main.java

static int getDistance(int rssi) {
    int irssi = Math.abs(rssi);
    double power = (irssi - 70.0) / (10 * 2.0);
    power = Math.pow(10d, power);
    power = power * 100;/*  ww w.j ava2s .c o  m*/
    return (int) power;
}

From source file:Main.java

public static double xround(double x, int num) {
    Log.e("---------- ", "" + x);
    return Math.round(x * Math.pow(10, num)) / Math.pow(10, num);
}

From source file:Main.java

private static float calDistance(float x1, float y1, float x2, float y2) {
    return (float) Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
}

From source file:Main.java

public static double calculateDPI(int width, int height, double screenSize) {
    return Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)) / screenSize;
}

From source file:Main.java

public static String randomCode(int length) {
    int seed = Double.valueOf(Math.pow(10, length)).intValue();
    return String.format("%0" + length + "d", (r.nextInt(seed)));
}

From source file:Main.java

public static double distanceBetweenPoints(double x1, double y1, double x2, double y2) {
    return Math.sqrt(Math.pow((x1 - x2), 2) + Math.pow((y1 - y2), 2));
}

From source file:Main.java

public static double absSquareSum(double[] input) {
    double sum = 0;
    for (int i = 0; i < input.length; i++) {
        sum += Math.pow(Math.abs(input[i]), 2);
    }/*from   ww w.  j a  va2s.c om*/
    return sum;
}

From source file:Main.java

static float quadTo(float startPoint, float endPoint, float targetPoint, float t) {
    return (float) (Math.pow(1.f - t, 2.f) * startPoint + 2.f * t * (1.f - t) * targetPoint
            + Math.pow(t, 2.f) * endPoint);
}