Here you can find the source of roundPositiveIntToPowerOf2(int i)
public static int roundPositiveIntToPowerOf2(int i)
//package com.java2s; //License from project: Apache License public class Main { public static int roundPositiveIntToPowerOf2(int i) { if (i <= 0) { throw new IllegalArgumentException(); }//from w w w.ja v a 2s. c o m return Integer.bitCount(i) == 1 ? i : Integer.highestOneBit(i) << 1; } }