Java Number Round roundUpLong(long x, long blockSizePowerOf2)

Here you can find the source of roundUpLong(long x, long blockSizePowerOf2)

Description

Round the value up to the next block size.

License

Apache License

Parameter

Parameter Description
x the value to be rounded
blockSizePowerOf2 the block size

Return

the rounded value

Declaration

public static long roundUpLong(long x, long blockSizePowerOf2) 

Method Source Code

//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);
    }
}

Related

  1. roundup_2n(long val, int blocksize)
  2. roundUpDivision(final int dividend, final int divider)
  3. roundUpDown(int number, int by)
  4. roundUpIfNecessary(long timeout, long convertedTimeout)
  5. roundUpLong(long value, long interval)
  6. roundUpNumberByUsingMultipleValue(double number, double multiple)
  7. roundUpPOT(int value)
  8. roundUpPow2(int x)
  9. roundUpPower2(int i)