## Class MathUtils

• public final class MathUtils
extends Object
Simple utilities for maths.
• ### Method Summary

All Methods
Modifier and Type Method Description
static boolean nearOne​(double value, double tolerance)
Checks if a number is near one.
static boolean nearZero​(double value, double tolerance)
Checks if a number is near zero.
static double pow2​(double value)
Returns the power of 2 (square).
static double pow3​(double value)
Returns the power of 3 (cube).
static double pow4​(double value)
Returns the power of 4.
• ### Method Detail

• #### pow2

public static double pow2​(double value)
Returns the power of 2 (square).
Parameters:
value - the value to check
Returns:
value * value
• #### pow3

public static double pow3​(double value)
Returns the power of 3 (cube).
Parameters:
value - the value to check
Returns:
value * value * value
• #### pow4

public static double pow4​(double value)
Returns the power of 4.
Parameters:
value - the value to check
Returns:
value * value * value * value
• #### nearZero

public static boolean nearZero​(double value,
double tolerance)
Checks if a number is near zero.

NaN and infinity are not near zero.

Parameters:
value - the value to check
tolerance - the tolerance, must be positive and not NaN/Infinite (not validated)
Returns:
true if near zero
• #### nearOne

public static boolean nearOne​(double value,
double tolerance)
Checks if a number is near one.

NaN and infinity are not near one.

Parameters:
value - the value to check
tolerance - the tolerance, must be positive and not NaN/Infinite (not validated)
Returns:
true if near one