List of usage examples for java.lang Math pow
@HotSpotIntrinsicCandidate public static double pow(double a, double b)
From source file:Main.java
public static double round(double value, int places) { if (places < 0) { throw new IllegalArgumentException(); }// w w w .ja v a2 s .co m long factor = (long) Math.pow(10, places); value = value * factor; long tmp = Math.round(value); return (double) tmp / factor; }
From source file:Main.java
public static double getPhysicalSize(Activity context) { DisplayMetrics dm = getScreenSize(context); double diagonalPixels = Math.sqrt(Math.pow(dm.widthPixels, 2) + Math.pow(dm.heightPixels, 2)); return diagonalPixels / (160 * dm.density); }
From source file:Main.java
public static Double round(double value, int precision) { int scale = (int) Math.pow(10, precision); return (double) Math.round(value * scale) / scale; }
From source file:Main.java
public static Double calculateEMI(Long principalAmount, double rateOfInterest, Long downPayment, double tenureInMonths) { Double emi = (((principalAmount - downPayment) * (rateOfInterest / (12 * 100))) * ((Math.pow((1 + (rateOfInterest / (12 * 100))), tenureInMonths)))) / ((Math.pow((1 + (rateOfInterest / (12 * 100))), tenureInMonths)) - 1); return emi;/* www. jav a 2 s. co m*/ }
From source file:Main.java
/** * Returns the square root of the sum of squares of its arguments, see {@link Math#hypot(double, double)} *///from ww w . j av a 2 s. c o m public static float hypo(int a, int b) { return (float) Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)); }
From source file:Main.java
public static double[] geoToMercator(double[] g) { double d = g[0] * Math.PI / 180, m = g[1] * Math.PI / 180, l = 6378137, k = 0.0818191908426, f = k * Math.sin(m);//from ww w. j a va 2s. com double h = Math.tan(Math.PI / 4 + m / 2), j = Math.pow(Math.tan(Math.PI / 4 + Math.asin(f) / 2), k), i = h / j; // return new DoublePoint(Math.round(l * d), Math.round(l * // Math.log(i))); return new double[] { l * d, l * Math.log(i) }; }
From source file:Main.java
private static <T extends Enum<T>> int enumSetToBitwise(EnumSet<T> enumSet) { int bitwise = 0; for (Enum<T> enumValue : enumSet) { bitwise += (int) Math.pow(2, enumValue.ordinal()); }/*from w w w. j a v a2 s . c om*/ return bitwise; }
From source file:Main.java
public static long[] getTileFromGeo(double lat, double lon, int zoom) { double rLon, rLat, a, k, z; rLon = lon * Math.PI / 180;//from w w w. j av a2 s .c o m rLat = lat * Math.PI / 180; a = 6378137; k = 0.0818191908426; z = Math.pow(Math.tan(Math.PI / 4 + rLat / 2) / (Math.tan(Math.PI / 4 + Math.asin(k * Math.sin(rLat)) / 2)), k); return new long[] { (int) (((20037508.342789 + a * rLon) * 53.5865938 / Math.pow(2, (23 - zoom))) / 256), (int) (((20037508.342789 - a * Math.log(z)) * 53.5865938 / Math.pow(2, (23 - zoom)))) / 256 }; }
From source file:Main.java
public static int byte2Int(byte b) { int ii = 0;//from ww w .j av a 2 s .com int temp = 0x01; if (b >= 0) return (int) b; for (int i = 0; i < 8; i++) { if ((b & (temp << i)) != 0) { ii += Math.pow(2, i); } } return ii; }
From source file:Main.java
public static double diffHsb(int hsb1[], final int hsb2[]) { if (hsb1 == null || hsb2 == null) { return 0.0; }/*from w w w . j ava2s .co m*/ if (hsb1.length < 3 || hsb2.length < 3) { return 0.0; } double h = Math.pow(hsb1[0] - hsb2[0], 2); double s = Math.pow(hsb1[1] - hsb2[1], 2); double b = Math.pow(hsb1[2] - hsb2[2], 2); return Math.sqrt(h + s + b); }