Here you can find the source of roundUpLong(long x, long blockSizePowerOf2)
Parameter | Description |
---|---|
x | the value to be rounded |
blockSizePowerOf2 | the block size |
public static long roundUpLong(long x, long blockSizePowerOf2)
//package com.java2s; //License from project: Apache License public class Main { /**//from www . j a va 2 s .co m * Round the value up to the next block size. The block size must be a power * of two. As an example, using the block size of 8, the following rounding * operations are done: 0 stays 0; values 1..8 results in 8, 9..16 results * in 16, and so on. * * @param x the value to be rounded * @param blockSizePowerOf2 the block size * @return the rounded value */ public static long roundUpLong(long x, long blockSizePowerOf2) { return (x + blockSizePowerOf2 - 1) & (-blockSizePowerOf2); } }