Here you can find the source of pow2(int i)
Parameter | Description |
---|---|
i | int i must be a non-negative number |
public static final int pow2(int i)
//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; } }