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 Bitmap revitionImageSize(String path) throws IOException { BufferedInputStream in = new BufferedInputStream(new FileInputStream(new File(path))); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true;/*from w w w . j a v a 2 s. co m*/ BitmapFactory.decodeStream(in, null, options); in.close(); int i = 0; Bitmap bitmap = null; while (true) { if ((options.outWidth >> i <= 1000) && (options.outHeight >> i <= 1000)) { in = new BufferedInputStream(new FileInputStream(new File(path))); options.inSampleSize = (int) Math.pow(2.0D, i); options.inJustDecodeBounds = false; bitmap = BitmapFactory.decodeStream(in, null, options); break; } i += 1; } return bitmap; }
From source file:Main.java
/** * <p>//w ww. j ava2 s. c o m * Calculates the bucket id the key should be placed in according to the * first n bits of the key where n is the power of 2 numBuckets is defined * as. F.e if 1024 buckets are defined the first 10 bits of the key will be * taken as the index for the actual bucket (2^10 = 1024, 2^9 = 512, ...) * </p> * * @param key * The 64bit key whose bucket index should be calculated * @param numBuckets * The total number of available buckets. This should be a power * of two (e.g. 2, 4, 8, 16, 32, ...) * @return The bucket index the key should be in */ public static int getBucketForKey(long key, final int numBuckets) { // test if numBuckets is a power of 2 int exponent = Math.getExponent(numBuckets); if (numBuckets != Math.pow(2, exponent)) throw new IllegalArgumentException("Number of buckets does not correspond to a power of 2!"); return (int) (key >> (64 - exponent)) + numBuckets / 2; }
From source file:Main.java
private static double xyz_rgb(double r) { return Math.round(255 * (r <= 0.00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - 0.055)); }
From source file:Main.java
/** * Returns the interpolated holographic highlight alpha for the effect we want when scrolling * pages./*from ww w. j ava 2 s .c om*/ */ public static float highlightAlphaInterpolator(float r) { float maxAlpha = 0.6f; return (float) Math.pow(maxAlpha * (1.0f - r), 1.5f); }
From source file:Main.java
public static int getScaledImageSize(int maxZoomLevel, int currZoomLevel, int size) { double scale = 1.0 / Math.pow(2, maxZoomLevel - currZoomLevel); return (int) Math.ceil(size * scale); }
From source file:Main.java
/** * Returns the interpolated view alpha for the effect we want when scrolling pages. *//*from w w w . jav a 2 s . c o m*/ public static float viewAlphaInterpolator(float r) { final float pivot = 0.95f; if (r < pivot) { return (float) Math.pow(r / pivot, 1.5f); } else { return 1.0f; } }
From source file:Main.java
public static Bitmap revitionImageSize(String path) { Bitmap bitmap = null;//from w ww . ja va 2 s . co m try { BufferedInputStream in = new BufferedInputStream(new FileInputStream(new File(path))); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeStream(in, null, options); in.close(); int i = 0; while (true) { if ((options.outWidth >> i <= 1000) && (options.outHeight >> i <= 1000)) { in = new BufferedInputStream(new FileInputStream(new File(path))); options.inSampleSize = (int) Math.pow(2.0D, i); options.inJustDecodeBounds = false; bitmap = BitmapFactory.decodeStream(in, null, options); break; } i += 1; } } catch (Exception e) { e.printStackTrace(); } return bitmap; }
From source file:Main.java
static public float getStationPressure(float altimHg, float elevMeters) { // Station pressure is in inHg return (float) (altimHg * Math.pow((288 - 0.0065 * elevMeters) / 288, 5.2561)); }
From source file:Main.java
public static float vectorMagnitudeSquare(float[] vector) { float accum = 0; for (int i = 0; i < vector.length; i++) { accum += Math.pow(vector[i], 2); }// w ww. java2 s . c om return Math.abs(accum); }
From source file:Main.java
public static Float getFloatValue(byte[] value, int format, int position) { if (value == null || (format & 15) + position > value.length) { return null; }//from w w w .j a va 2 s. com switch (format) { case FORMAT_SFLOAT /*50*/: int i = value[position + FIRST_BITMASK]; return Float.valueOf( (float) (((double) signed((value[position] & 255) + (((i & 255) & 15) << FOURTH_BITMASK), 12)) * Math.pow(10.0d, (double) signed((i & 255) >> THIRD_BITMASK, THIRD_BITMASK)))); case FORMAT_FLOAT /*52*/: int exponent = value[position + CategoryIDVoicemail]; int mantissa = value[position + SECOND_BITMASK]; return Float.valueOf((float) (((double) signed( ((value[position] & 255) + ((value[position + FIRST_BITMASK] & 255) << FOURTH_BITMASK)) + ((mantissa & 255) << FIFTH_BITMASK), 24)) * Math.pow(10.0d, (double) exponent))); default: return null; } }