Java Ceil ceilToPowerOfTwo(float value)

Here you can find the source of ceilToPowerOfTwo(float value)

Description

Ceils the given value to the closest number that's is a power of two.

License

Open Source License

Parameter

Parameter Description
value a parameter

Declaration

public static int ceilToPowerOfTwo(float value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//  www.  ja  v  a 2s .  c  om
     * Ceils the given value to the closest number that's is a power
     * of two.
     * @param value
     * @returns closest number that's a power of two
     */
    public static int ceilToPowerOfTwo(float value) {
        int size = 2;

        while (size < value) {
            size *= 2;
        }

        return size;
    }
}

Related

  1. ceilPowerOf2(int x)
  2. ceilPowerOf2Bits(final long x)
  3. ceilPrime(long p)
  4. ceilSec(long milli)
  5. ceilToBase(int number, int base)
  6. ceilToQuarterMs(float f)
  7. ceilU(final float value)
  8. ceily(double a, double precision)