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 getLat(int inY, int zoom) { double y = Math.floor(inY * 256); double efactor = Math.exp((0.5 - y / 256 / Math.pow(2, zoom)) * 4 * Math.PI); double latitude = Math.asin((efactor - 1) / (efactor + 1)) * 180 / Math.PI; if (latitude < -90.0) { latitude = -90.0;//from w w w . j a v a 2 s. c om } else if (latitude > 90.0) { latitude = 90.0; } return latitude; }
From source file:Main.java
private static byte bits2byteReverse(String bString) { byte result = 0; for (int i = 0, j = 0; i < 8; i++, j++) { result += (Byte.parseByte(bString.charAt(i) + "") * Math.pow(2, j)); }//from ww w .j av a 2 s. co m return result; }
From source file:Main.java
private static double convertColorPart(double colorPart) { colorPart /= 255.0;/*from w w w . jav a 2 s . c o m*/ if (colorPart <= 0.03928) { return colorPart / 12.92; } else { return Math.pow(((colorPart + 0.055) / 1.055), 2.4); } }
From source file:Main.java
public static double calculateIndoorDistance(double level, double freq) { double exp = (27.55d - 40d * Math.log10(freq) + 6.7d - level) / 20.0d; return Math.pow(10.0d, exp); }
From source file:Main.java
public static float getEuclideanDistance(float[] arr1, float[] arr2) { float minSum = 0; for (int i = 0; i < arr1.length; i++) { minSum += Math.pow(arr1[i] - arr2[i], 2); }//from w w w. j a v a 2 s . c om return minSum; }
From source file:Main.java
private static byte bits2byte(String bString) { byte result = 0; for (int i = bString.length() - 1, j = 0; i >= 0; i--, j++) { result += (Byte.parseByte(bString.charAt(i) + "") * Math.pow(2, j)); }// w ww . j a v a 2s . c om return result; }
From source file:Main.java
public static double magic_func(double t) { double bound = 0.04045; double a = 0.055; double gamma = 2.4; double denom = 12.92; if (t > bound) { return Math.pow((t + a) / (1 + a), gamma); } else {// w w w . j a va2s.com return t / denom; } }
From source file:Main.java
public static long productOfDigit(int[] digits) { long result = 1; for (int i = 9; i >= 0; i--) { if (digits[i] != 0) { result *= Math.pow(i, digits[i]); }/*from www. ja v a2 s .com*/ } return result; }
From source file:Main.java
/** * Check if one double value equals to zero * @param obj//from www .j av a 2 s . c o m * @param precision * @return */ public static boolean equalsToZero(double obj, int precision) { return Math.abs(obj) <= Math.pow(0.1, precision); }
From source file:Main.java
public static int ByteIntValue(byte b) { int toReturn = 0; for (int i = 0; i < 8; i++) { if (GetBit(b, 0)) { toReturn += Math.pow(2, i); }//from w w w. j av a2 s . c o m } return toReturn; }