Example usage for java.lang Math floor

List of usage examples for java.lang Math floor

Introduction

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

Prototype

public static double floor(double a) 

Source Link

Document

Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer.

Usage

From source file:Main.java

public static char randomDecimalDigit() {
    return digits[(int) Math.floor(Math.random() * 10)];
}

From source file:Main.java

public static int numberRoll(double number) {
    return (int) Math.floor(number);
}

From source file:Main.java

public static int getPowerOfTwoForSampleRatio(double ratio) {
    int k = Integer.highestOneBit((int) Math.floor(ratio));
    if (k == 0)//from  w  w w  .  j av a 2 s .  c  o m
        return 1;
    else
        return k;
}

From source file:Main.java

private static int getPowerOfTwoForSampleRatio(double ratio) {
    int k = Integer.highestOneBit((int) Math.floor(ratio));
    if (k == 0)//www .  j  av  a 2 s.  c  o m
        return 1;
    else
        return k;
}

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  ava 2s .co m
    } else if (latitude > 90.0) {
        latitude = 90.0;
    }
    return latitude;
}

From source file:Main.java

public static double getLong(int inX, int zoom) {
    double x = Math.floor(inX * 256);
    double longitude = ((x * 360) / (256 * Math.pow(2, zoom))) - 180;
    while (longitude > 180.0) {
        longitude -= 360.0;/*from   w w w  . j  a v  a  2  s . c  o m*/
    }
    while (longitude < -180.0) {
        longitude += 360.0;
    }
    return longitude;

}

From source file:Main.java

public static int[] getYearMonthFromEraMonthIndex(int eraMonthIndex) {
    int[] result = new int[2];

    result[0] = (int) Math.floor(eraMonthIndex / 12); // year
    result[1] = (eraMonthIndex % 12); // month

    return result;
}

From source file:Main.java

public static long roundMillisToDate(double aMillis) {
    Double dateInMillis = Math.floor(aMillis / 86400000) * MILLIS_IN_DAY;
    return dateInMillis.longValue();
}

From source file:Main.java

private static double zoom(int mapPx, int worldPx, double fraction) {
    return Math.floor(Math.log(mapPx / worldPx / fraction) / LN2);
}

From source file:Main.java

public static long m11351a(long j, int i, int i2) {
    return (((long) (i < 7 ? i * 31 : (i * 30) + 6)) + ((1029983
            * ((long) Math.floor(((double) (j - 474)) / 2820.0d)))
            + (((365 * ((m11349a((double) (j - 474), 2820.0d) + 474) - 1)) + ((long) Math
                    .floor(((double) ((682 * (m11349a((double) (j - 474), 2820.0d) + 474)) - 110)) / 2816.0d)))
                    + 1948320)))// www. j  av  a2  s.  co  m
            + ((long) i2);
}