Here you can find the source of roundToPowerOf(int i, int powerOf)
public static final int roundToPowerOf(int i, int powerOf)
//package com.java2s; // {LICENSE}/*from w ww . j a va 2 s. c o m*/ public class Main { public static final int roundToPowerOf(int i, int powerOf) { int j = 0; while (true) { j++; int k = pow(powerOf, j); if (k >= i) return k; } } public static final int pow(int i, int pow) { if (pow == 0 || i == 0) return 1; int r = i; if (pow > 0) { for (int j = 0; j < pow; j++) { r *= i; } } else { for (int j = 0; j < -pow; j++) { r /= i; } } return r; } }