# Class: com.pnfsoftware.jeb.util.math.MathUtil

Set of common operations on [Number](Number) that are not in [Math](Math).

## Constructor: MathUtil


## Static Method: almostEquals
- parameter: `a`, type: `double`
- parameter: `b`, type: `double`
- return type: `boolean`

Description: Check for almost equality: tolerate a 1e\-7 gap to make up for numerical errors inherent to IEEE754 calculations.
parameter: a: 
parameter: b: 
return: true if \|a\-b\|<=1e\-7

## Static Method: almostEquals
- parameter: `a`, type: `double`
- parameter: `b`, type: `double`
- parameter: `epsilon`, type: `double`
- return type: `boolean`

Description: Check for almost equality: tolerate an epsilon gap to make up for numerical errors inherent to IEEE754 calculations.
parameter: a: 
parameter: b: 
parameter: epsilon: a positive number
return: true if \|a\-b\|<=epsilon

## Static Method: avg
- parameter: `collection`, type: `java.util.Collection<? extends java.lang.Number>`
- return type: `double`


## Static Method: avg
- parameter: `array`, type: `byte[]`
- return type: `double`


## Static Method: avg
- parameter: `array`, type: `char[]`
- return type: `double`


## Static Method: avg
- parameter: `array`, type: `short[]`
- return type: `double`


## Static Method: avg
- parameter: `array`, type: `int[]`
- return type: `double`


## Static Method: avg
- parameter: `array`, type: `long[]`
- return type: `double`


## Static Method: avg
- parameter: `array`, type: `float[]`
- return type: `double`


## Static Method: avg
- parameter: `array`, type: `double[]`
- return type: `double`


## Static Method: betweenExclusive
- parameter: `value`, type: `long`
- parameter: `min`, type: `long`
- parameter: `max`, type: `long`
- return type: `boolean`

Description: Check that a value is between two bounds \(exclusive\)
parameter: value: value
parameter: min: min bound
parameter: max: max bound
return: true if when value is in range \]min, max\[

## Static Method: betweenInclusive
- parameter: `value`, type: `long`
- parameter: `min`, type: `long`
- parameter: `max`, type: `long`
- return type: `boolean`

Description: Check that a value is between two bounds \(inclusive\)
parameter: value: value
parameter: min: min bound
parameter: max: max bound
return: true if when value is in range \[min, max\]

## Static Method: bitcount
- parameter: `value`, type: `int`
- return type: `int`


## Static Method: bitcount
- parameter: `value`, type: `long`
- return type: `int`


## Static Method: isPowerOfTwo
- parameter: `n`, type: `int`
- return type: `boolean`

Description: Determine is a strictly positive integer is a power of 2.
parameter: n: a positive integer
return: 

## Static Method: isPowerOfTwo
- parameter: `n`, type: `long`
- return type: `boolean`

Description: Determine is a strictly positive integer is a power of 2.
parameter: n: a positive integer
return: 

## Static Method: log2
- parameter: `n`, type: `int`
- return type: `int`

Description: Get the truncated base2 log of the input.
parameter: n: must be strictly positive
return: 

## Static Method: log2
- parameter: `n`, type: `long`
- return type: `int`

Description: Get the truncated base2 log of the input.
parameter: n: must be strictly positive
return: 

## Static Method: makeInverseMask
- parameter: `bitsize`, type: `int`
- return type: `long`

Description: Create a 64\-bit inverse mask. Safe replacement for `~((ONE << BITSIZE) - ONE)` constructs.
parameter: bitsize: bitsize \[0, 64\]
return: the inverse mask
throws: if the bitsize is OOR

## Static Method: makeMask
- parameter: `bitsize`, type: `int`
- return type: `long`

Description: Create a 64\-bit mask. Safe replacement for `(ONE << BITSIZE) - ONE` constructs.
parameter: bitsize: bitsize \[0, 64\]
return: the mask
throws: if the bitsize is OOR

## Static Method: makeOverflow
- parameter: `bitsize`, type: `int`
- return type: `long`

Description: Create a 64\-bit overflow. Safe replacement for `(ONE << BITSIZE)` constructs.
parameter: bitsize: bitsize \[0, 64\]
return: the overflow
throws: if the bitsize is OOR

## Static Method: minPositive
- parameter: `values`, type: `int[]`
- return type: `int`

Description: Get the min of the values which is \> 0. \(for example when looking for min indexOf\)

## Static Method: moduloPositive
- parameter: `a`, type: `int`
- parameter: `b`, type: `int`
- return type: `int`

Description: Calculate the positive remainder of two integers. 

 Note: Java standard modulo operators specifies that the remainder will have the sign of the numerator. This method provides an alternate way to calculate the remainder, often\-time more useful, by making sure that it remains positive.
parameter: a: any integer
parameter: b: a strictly positive integer
return: positive remainder

## Static Method: msb
- parameter: `value`, type: `long`
- parameter: `bitsize`, type: `int`
- return type: `int`

Description: 
parameter: value: 
parameter: bitsize: must be in \[0, 64\]
return: 

## Static Method: pow
- parameter: `a`, type: `int`
- parameter: `b`, type: `int`
- return type: `int`

Description: Integer exponentiation.
parameter: a: 
parameter: b: 
return: a\*\*b \(may have overflowed\)

## Static Method: pow
- parameter: `a`, type: `long`
- parameter: `b`, type: `long`
- return type: `long`

Description: Long int exponentiation.
parameter: a: 
parameter: b: 
return: a\*\*b \(may have overflowed\)

## Static Method: signExtend
- parameter: `value`, type: `long`
- parameter: `bitsize`, type: `int`
- return type: `long`

Description: 
parameter: value: 
parameter: bitsize: must be in \[0, 64\]
return: 

## Static Method: signExtend32
- parameter: `value`, type: `long`
- parameter: `bitsize`, type: `int`
- return type: `long`

Description: 
parameter: value: 
parameter: bitsize: must be in \[0, 32\]
return: 

## Static Method: signExtend32
- parameter: `value`, type: `int`
- parameter: `bitsize`, type: `int`
- return type: `int`

Description: 
parameter: value: 
parameter: bitsize: must be in \[0, 32\]
return: 

## Static Method: unmaskedArithShiftRight
- parameter: `v`, type: `long`
- parameter: `cnt`, type: `int`
- return type: `long`


## Static Method: unmaskedShiftLeft
- parameter: `v`, type: `long`
- parameter: `cnt`, type: `int`
- return type: `long`


## Static Method: unmaskedShiftRight
- parameter: `v`, type: `long`
- parameter: `cnt`, type: `int`
- return type: `long`


## Static Method: zeroExtend
- parameter: `value`, type: `long`
- parameter: `bitsize`, type: `int`
- return type: `long`

Description: 
parameter: value: 
parameter: bitsize: must be in \[0, 64\]
return: 

## Static Method: zeroExtend32
- parameter: `value`, type: `long`
- parameter: `bitsize`, type: `int`
- return type: `long`

Description: 
parameter: value: 
parameter: bitsize: must be in \[0, 32\]
return: 

