Here you can find the source of nextPowerOfTwo(int value)
public static int nextPowerOfTwo(int value)
//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))); } }