Java Number Power pow2(int i)

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

Description

2^i

License

Open Source License

Parameter

Parameter Description
i int i must be a non-negative number

Return

int 2^i

Declaration

public static final int pow2(int i) 

Method Source Code

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

public class Main {
    /**/*from   w w  w  .  j  ava 2  s  .co m*/
     * 2^i
     * @param i int i must be a non-negative number
     * @return int 2^i
     */
    public static final int pow2(int i) {
        if (i < 0)
            return 0;
        int result = 1;
        for (int k = 0; k < i; k++)
            result *= 2;
        return result;
    }
}

Related

  1. pow2(double x, int n)
  2. pow2(final int a)
  3. pow2(final int n)
  4. pow2(final int x)
  5. pow2(int c)
  6. pow2(long x)
  7. Pow2(Object in, double val)
  8. pow2ByteIndex(final int x)
  9. pow3_strict(final float a)