Here you can find the source of floorToPowerofTwo(int i)
public static int floorToPowerofTwo(int i)
//package com.java2s; //License from project: Apache License public class Main { public static int floorToPowerofTwo(int i) { //returns the closest lower power of to from i int r = 1; for (int c = 1; c <= i; c *= 2) { r = c;/*from w ww . ja v a2 s . c o m*/ } return r; } }