Example usage for java.lang Math ceil

List of usage examples for java.lang Math ceil

Introduction

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

Prototype

public static double ceil(double a) 

Source Link

Document

Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer.

Usage

From source file:Main.java

public static float roundToHalf(float x) {
    return (float) (Math.ceil(x * 2) / 2);
}

From source file:Main.java

public static int px2dp(float density, int px) {
    return (int) Math.ceil(px / density);
}

From source file:Main.java

public static int GetNearestBarWeight(float weight) {
    return (int) Math.ceil(weight / 5) * 5;
}

From source file:Main.java

public static int px2sp(float scaledDensity, int px) {
    return (int) Math.ceil(px / scaledDensity);
}

From source file:Main.java

public static int computeNewSize(final int inputSize) {
    return (int) Math.ceil((inputSize * 3.0) / 2.0);
}

From source file:Main.java

public static int dp(float value) {
    return (int) Math.ceil(density * value);
}

From source file:Main.java

public static int sp(float value) {
    return (int) Math.ceil(scaledDensity * value);
}

From source file:Main.java

public static int getBlockNum(File file, int blockSize) {
    return (int) Math.ceil(file.length() / (double) blockSize);
}

From source file:Main.java

public static int getStatusBarHeight(Context context) {
    return (int) Math.ceil(25 * context.getResources().getDisplayMetrics().density);
}

From source file:Main.java

public static String[] splitByLength(String s, int chunkSize) {
    int arraySize = (int) Math.ceil((double) s.length() / chunkSize);

    String[] returnArray = new String[arraySize];

    int index = 0;
    for (int i = 0; i < s.length(); i = i + chunkSize) {
        if (s.length() - i < chunkSize) {
            returnArray[index++] = s.substring(i);
        } else {//from  ww  w .  ja v  a  2s.c  o m
            returnArray[index++] = s.substring(i, i + chunkSize);
        }
    }

    return returnArray;
}