Maven module :un.api : api-common :
Class : un.api.number.Numbers
Extends/Implements : -
Subclasses : -

Utility functions for numbers.
author  Bertrand Cote
author  Johann Sorel


Variables : HEXA
Functions : isNotPowOfTwo, nextPowOfTwo, reverseBits, setBit, setBit, countBitsSet, pow, pow


public byte[] HEXA



Return True if n is not a power of 2.
param  n a positive integer
return  True if n is not a power of 2
public boolean isNotPowOfTwo (int n)


Return the nearest pow of two higher or equal to n.
param  n value
return  nearest pow of two higher or equal to n.
public int nextPowOfTwo (int n)


Reverses the bits order of x in a nBits length integer.
E.g:
x=4 nBits=3
x=4=100b then returns 001b=1
x=7 nBits=4
x=7=0111b then returns 1110b=13
param  i value
param  nBits number of bits of x
return  x in reverse bits order
public int reverseBits (int i, int nBits)


Set one bit value in an int.
param  value
param  bit
param  offset
return
public int setBit (int value, boolean bit, int offset)


Set one bit value in an int.
param  value
param  bit
param  offset
return
public long setBit (long value, boolean bit, int offset)


Count number of bits set to 1 in given integer.

http://en.wikipedia.org/wiki/Hamming_weight
http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel

@param i
@return number of bit set to 1 .
public int countBitsSet (int i)



public float pow (float x, int n)

public double pow (double x, int n)