jbarrier

edu.bonn.cs.net.jbarrier.util
Class Utils

java.lang.Object
  extended by edu.bonn.cs.net.jbarrier.util.Utils

public class Utils
extends java.lang.Object

Utility functions for computing powers of two.

Version:
1.0
Author:
Patrick Peschlow, Ivan Castilla Rodriguez

Constructor Summary
Utils()
           
 
Method Summary
static boolean isPowerOfTwo(int k)
          Checks whether the provided integer is a power of two.
static int nextHigherPowerOfTwo(int k)
          Computes the next higher power of two of the provided integer.
static int powerOfTwo(int n)
          Computes the n-th integer power of two.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

nextHigherPowerOfTwo

public static int nextHigherPowerOfTwo(int k)
Computes the next higher power of two of the provided integer.

Parameters:
k - the provided integer
Returns:
the next higher power of two of k

powerOfTwo

public static int powerOfTwo(int n)
Computes the n-th integer power of two.

Parameters:
n - the provided integer
Returns:
the n-th power of two

isPowerOfTwo

public static boolean isPowerOfTwo(int k)
Checks whether the provided integer is a power of two.

Parameters:
k - the provided integer
Returns:
true if the provided integer is a power of two, otherwise false

jbarrier

Copyright 2010 Patrick Peschlow