Android examples for java.lang:Math
get Closest Power Of Two
//package com.java2s; public class Main { public static int getClosestPowerOfTwo(int value) { value--;// ww w . j av a2s . c o m value |= value >> 1; value |= value >> 2; value |= value >> 4; value |= value >> 8; value |= value >> 16; if (value == Integer.MAX_VALUE) return Integer.MAX_VALUE; value++; return value; } }