Java Number Round roundUpToPowerOfTwo(int p_151236_0_)

Here you can find the source of roundUpToPowerOfTwo(int p_151236_0_)

Description

Returns the input value rounded up to the next highest power of two.

License

Open Source License

Declaration

public static int roundUpToPowerOfTwo(int p_151236_0_) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from w w w  .  ja  v  a  2 s.  c  om*/
     * Returns the input value rounded up to the next highest power of two.
     */
    public static int roundUpToPowerOfTwo(int p_151236_0_) {
        int j = p_151236_0_ - 1;
        j |= j >> 1;
        j |= j >> 2;
        j |= j >> 4;
        j |= j >> 8;
        j |= j >> 16;
        return j + 1;
    }
}

Related

  1. roundUpToNearestPowerOfTwoIfGreaterThanZero(final int value)
  2. roundUpToPowerOf2(int number)
  3. roundUpToPowerOf2(long val)
  4. roundUpToPowerOf2Factor(long val, long factor)
  5. roundUpToPowerOfTwo(int i)
  6. roundUpToPowerOfTwo(int v)
  7. roundUpToPowerOfTwo(int x)
  8. roundUpToTheNextHighestPowerOf2(int v)
  9. roundUpToTwo(Double number)