Java Number Round roundPositiveIntToPowerOf2(int i)

Here you can find the source of roundPositiveIntToPowerOf2(int i)

Description

round Positive Int To Power Of

License

Apache License

Declaration

public static int roundPositiveIntToPowerOf2(int i) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static int roundPositiveIntToPowerOf2(int i) {
        if (i <= 0) {
            throw new IllegalArgumentException();
        }//from  w  w  w.ja  v a 2s.  c  o m
        return Integer.bitCount(i) == 1 ? i : Integer.highestOneBit(i) << 1;
    }
}

Related

  1. roundOffValues(double[] doubles)
  2. roundPhred(final double value, final double phredScorePrecision)
  3. roundPos(final float a)
  4. roundPositive(float value)
  5. roundPositive(float x)
  6. roundPower10(float val, int powerOf10)
  7. roundPower2(final long x)
  8. roundRadian(double rad)
  9. roundRobin(final int value)