Java Number Round roundPower2(final long x)

Here you can find the source of roundPower2(final long x)

Description

Finds greater nearest number that is power of 2

License

Open Source License

Return

long

Declaration

public static long roundPower2(final long x) 

Method Source Code

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

public class Main {
    /**//  w ww. j a  v  a  2  s .com
     * Finds greater nearest number that is power of 2
     * @return long
     */
    public static long roundPower2(final long x) {
        int rval = 256;

        while (rval < x)
            rval <<= 1;

        return rval;
    }
}

Related

  1. roundPos(final float a)
  2. roundPositive(float value)
  3. roundPositive(float x)
  4. roundPositiveIntToPowerOf2(int i)
  5. roundPower10(float val, int powerOf10)
  6. roundRadian(double rad)
  7. roundRobin(final int value)
  8. roundScale(double value, int scale)
  9. roundScale2(Number number)