Here you can find the source of nextPowerOfTwo(int x)
Parameter | Description |
---|---|
x | the minimum value to return |
public static int nextPowerOfTwo(int x)
//package com.java2s; /*// w w w .jav a 2 s . co m * MathUtil.java * Eisenkraut * * Copyright (c) 2004-2015 Hanns Holger Rutz. All rights reserved. * * This software is published under the GNU General Public License v3+ * * * For further information, please contact Hanns Holger Rutz at * contact@sciss.de */ public class Main { /** * Calculates an integer that is a power * of two and is equal or greater than a given integer * * @param x the minimum value to return * @return an integer 2^n which is equal or greater than x */ public static int nextPowerOfTwo(int x) { int y; for (y = 1; y < x; y <<= 1) ; return y; } }