Java Power of 2 nextPowerOfTwo(int value)

Here you can find the source of nextPowerOfTwo(int value)

Description

Rounds the specified value up to the next nearest power of two.

License

Open Source License

Declaration

public static int nextPowerOfTwo(int value) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from  w  w  w  .j a  va2s . c o  m*/
     * Rounds the specified value up to the next nearest power of two.
     */
    public static int nextPowerOfTwo(int value) {
        return (int) Math.pow(2, Math.ceil(Math.log(value) / Math.log(2)));
    }
}

Related

  1. nextPowerOfTwo(int i)
  2. nextPowerOfTwo(int n)
  3. nextPowerOfTwo(int num)
  4. nextPowerOfTwo(int value)
  5. nextPowerOfTwo(int value)
  6. nextPowerOfTwo(int value)
  7. nextPowerOfTwo(int x)
  8. nextPowerOfTwo(int x)
  9. nextPowerOfTwo(int x)