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 float[] LABtoXYZ(Float L, float a, float b) { float y = (L + 16f) / 116f; float x = a / 500f + y; float z = y - b / 200f; if (Math.pow(y, 3f) > 0.008856f) { y = (float) Math.pow(y, 3f); } else {/*from w ww .jav a2 s .c o m*/ y = (y - 16f / 116f) / 7.787f; } if (Math.pow(x, 3f) > 0.008856f) { x = (float) Math.pow(x, 3f); } else { x = (x - 16f / 116f) / 7.787f; } if (Math.pow(z, 3f) > 0.008856f) { z = (float) Math.pow(z, 3f); } else { z = (z - 16f / 116f) / 7.787f; } x = 95.047f * x; y = 100.000f * y; z = 108.883f * z; return new float[] { x, y, z }; }
From source file:Main.java
public static int binaryToAlgorism(String binary) { int max = binary.length(); int result = 0; for (int i = max; i > 0; i--) { char c = binary.charAt(i - 1); int algorism = c - '0'; result += Math.pow(2, max - i) * algorism; }// w w w . j a va2s . co m return result; }
From source file:Main.java
public static double calculateHalfByteBCDFromByteArrayAtBaseTen(byte[] b) { int power = 0; double result = 0.0; for (int i = b.length - 1; i >= 0; i--) { byte last = b[i]; double l = (int) (last & 0x0F) * 0.1 * Math.pow(10, power); double l2 = (int) (last & 0xF0) * 0.1 * Math.pow(10, power + 1); result += l2 + l;/* w ww . j ava2s.c o m*/ power = power + 2; } return result; }
From source file:Main.java
static public double calculateAccuracy(int txPower, double rssi) { if (rssi == 0) { return -1.0; // if we cannot determine accuracy, return -1. }// w w w . j av a2s . c om double ratio = rssi * 1.0 / txPower; if (ratio < 1.0) { return Math.pow(ratio, 10); } else { double accuracy = (0.89976) * Math.pow(ratio, 7.7095) + 0.111; return accuracy; } }
From source file:Main.java
/************************************** * Math relevant/*from w w w. j a v a 2 s. c o m*/ *************************************/ public static double calculatePDFOfNormalDistribution(double mean, double std, double value) { double prob = Math.pow(Math.E, -Math.pow(value - mean, 2) / 2 / Math.pow(std, 2)) / (Math.sqrt(Math.PI * 2) * std); if (prob > 1) System.out.println(mean + " " + std + " " + value); return prob; }
From source file:Main.java
public static int scalePow2(int height, int width) { int scale = 1; int size = Math.max(height, width); if (size > IMAGE_MAX_SIZE) { scale = (int) Math.pow(2, (int) Math.round(Math.log(IMAGE_MAX_SIZE / (double) size) / Math.log(0.5))); }/*from w ww . ja va 2 s .c o m*/ return scale; }
From source file:Main.java
public static int calculateAccuracy(int txPower, double rssi) { if (rssi == 0) { return -100; // if we cannot determine accuracy, return -1. }//from w w w .j av a2s .c o m double ratio = rssi * 1.0 / txPower; if (ratio < 1.0) { return (int) (100 * Math.pow(ratio, 10)); } else { double accuracy = (0.89976) * Math.pow(ratio, 7.7095) + 0.111; return (int) (100 * accuracy); } }
From source file:Main.java
public static boolean isTablet(Activity activity) { DisplayMetrics dm = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(dm); double diagonalPixels = Math.sqrt(Math.pow(dm.widthPixels, 2) + Math.pow(dm.heightPixels, 2)); double physicalSize = diagonalPixels / (160 * dm.density); return physicalSize > 7; }
From source file:Main.java
/** * Function that rounds a number to N decimal places * /*from ww w . j a v a2 s .c om*/ * @param d * Double to round * @param n * Number of decimal places to round to * @return */ public static double roundn(double d, int n) { d = d * Math.pow(10, n); d = Math.round(d); d = d / Math.pow(10, n); return d; }
From source file:Main.java
public static String doFormatarTamanho(long bytes) { int unit = 1024; if (bytes < unit) return bytes + " B"; int exp = (int) (Math.log(bytes) / Math.log(unit)); char pre = "KMGTPE".charAt(exp - 1); return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre); }