Java Number Power pow2(final int x)

Here you can find the source of pow2(final int x)

Description

Simple 2^x

License

Open Source License

Parameter

Parameter Description
x power

Return

2^x

Declaration

public static int pow2(final int x) 

Method Source Code

//package com.java2s;
/**//  ww w  .ja  va  2s .c o m
 * Copyright (c) 2008-2012 Ardor Labs, Inc.
 *
 * This file is part of Ardor3D.
 *
 * Ardor3D is free software: you can redistribute it and/or modify it 
 * under the terms of its license which may be found in the accompanying
 * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
 */

public class Main {
    /**
     * Simple 2^x
     * 
     * @param x
     *            power
     * @return 2^x
     */
    public static int pow2(final int x) {
        if (x <= 0) {
            return 1;
        }
        return 2 << x - 1;
    }
}

Related

  1. pow2(double base, double power)
  2. pow2(double num)
  3. pow2(double x, int n)
  4. pow2(final int a)
  5. pow2(final int n)
  6. pow2(int c)
  7. pow2(int i)
  8. pow2(long x)
  9. Pow2(Object in, double val)