Android examples for java.lang:Math
next Power Of Two
/*/* w ww .j a va2 s .c om*/ * Copyright (c) 2012-2013 OrangeSignal.com All Rights Reserved. */ //package com.java2s; public class Main { public static int nextPowerOfTwo(final int x) { return (int) Math.pow(2, Math.ceil(log2(x))); } public static double log2(final double x) { return Math.log(x) / Math.log(2); } }