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

private static String getMinutesString(float value) {
    int hour = (int) (value / 60);
    int minutes = (int) Math.ceil(value - (hour * 60));
    return addAZeroIfNeeds(minutes == 60 ? 0 : minutes);
}

From source file:Main.java

public static int getMapCapacityForExpectedSize(int expectedSize) {
    return (int) Math.ceil(expectedSize / 0.75);
}

From source file:Main.java

public static int YUVFrameByteSize(int wid, int hei) {
    int yStride = (int) Math.ceil(wid / 16.0) * 16;
    int uvStride = (int) Math.ceil((yStride / 2) / 16.0) * 16;
    int ySize = yStride * hei;
    int uvSize = uvStride * hei / 2;
    return ySize + uvSize * 2;
}

From source file:Main.java

public static int getYuvBuffer(int width, int height) {
    // stride = ALIGN(width, 16)
    int stride = (int) Math.ceil(width / 16.0) * 16;
    // y_size = stride * height
    int y_size = stride * height;
    // c_stride = ALIGN(stride/2, 16)
    int c_stride = (int) Math.ceil(width / 32.0) * 16;
    // c_size = c_stride * height/2
    int c_size = c_stride * height / 2;
    // size = y_size + c_size * 2
    return y_size + c_size * 2;
}

From source file:Main.java

public static double calculateMinZoomLevel(int width, int height, int tileSize) {
    int max = Math.max(width, height);
    int tilesCount = (int) Math.ceil(1d * max / tileSize);
    return Math.ceil(Math.log(tilesCount) / Math.log(2d));
}

From source file:Main.java

public static int getTextHeight(Paint paint) {
    Paint.FontMetrics fm = paint.getFontMetrics();
    return (int) Math.ceil(fm.descent - fm.ascent);
}

From source file:Main.java

public static RectF ceil(final RectF rect) {
    rect.left = (float) Math.ceil(rect.left);
    rect.top = (float) Math.ceil(rect.top);
    rect.right = (float) Math.ceil(rect.right);
    rect.bottom = (float) Math.ceil(rect.bottom);
    return rect;/*from  ww w  .ja  v  a2s . co m*/
}

From source file:Main.java

public static int getTextFullHeight(Paint paint) {
    Paint.FontMetrics fm = paint.getFontMetrics();
    return (int) Math.ceil(fm.bottom - fm.top);
}

From source file:Main.java

public static float getTextHeight(Paint paint) {
    Paint.FontMetrics fm = paint.getFontMetrics();
    return (float) (Math.ceil(fm.descent - fm.ascent) + 2f);
}

From source file:Main.java

public static byte[][] chunkArray(byte[] array, int chunkSize) {
    int numOfChunks = (int) Math.ceil((double) array.length / chunkSize);
    byte[][] output = new byte[numOfChunks][];

    for (int i = 0; i < numOfChunks; ++i) {
        int start = i * chunkSize;
        int length = Math.min(array.length - start, chunkSize);

        byte[] temp = new byte[length];
        System.arraycopy(array, start, temp, 0, length);
        output[i] = temp;//from  w  ww.  ja v  a 2 s  .  co  m
    }

    return output;
}