Utility functions for mathematical calculations.

Available since

1.0.0

.

### `@:value({ maxDifference : 0.000001 })staticfuzzyEquals(n1:Float, n2:Float, maxDifference:Float = 0.000001):Bool`

Compares two `Float` values in a way that they are considered equal if their difference is below a certain threshold. Useful for meaningful comparisons between numbers that may be slightly different due to floating point errors.

Parameters:

`n1` the first number to compare the second number to compare the maximum difference between the two numbers to be considered equal

Returns:

true if the numbers are considered equal

### `@:value({ nearest : 1.0 })staticroundDownToNearest(number:Float, nearest:Float = 1.0):Float`

Rounds a number down to the nearest multiple of an input. For example, by rounding `16` down to the nearest `10`, you will receive `10`, and by rounding `26` down to the nearest `10`, you will receive `20`. Similar to the built-in function `Math.floor()`.

Parameters:

`numberToRound` the number to round down the number whose mutiple must be found

Returns:

the rounded number

Available since

1.0.0

.

• `Math.floor`

• `Math.ffloor`

### `@:value({ nearest : 1.0 })staticroundToNearest(number:Float, nearest:Float = 1.0):Float`

Rounds a number to the nearest multiple of an input. For example, by rounding `26` to the nearest `10`, you will receive `30`, and by rounding `24` to the nearest `10`, you will receive `20`. Similar to the built-in function `Math.round()`.

Parameters:

`numberToRound` the number to round the number whose mutiple must be found

Returns:

the rounded number

Available since

1.0.0

.

• `Math.round`

• `Math.fround`

### `@:value({ precision : 0 })staticroundToPrecision(number:Float, precision:Int = 0):Float`

Rounds a number to a certain level of decimal precision. Useful for limiting the number of decimal places on a fractional number.

Parameters:

`number` the input number to round. the number of decimal digits to keep

Returns:

the rounded number, or the original input if no rounding is needed

Available since

1.0.0

.

### `@:value({ nearest : 1.0 })staticroundUpToNearest(number:Float, nearest:Float = 1.0):Float`

Rounds a number up to the nearest multiple of an input. For example, by rounding `16` up to the nearest `10`, you will receive `20`, and by rounding `26` up to the nearest `10`, you will receive `30`. Similar to the built-in function `Math.ceil()`.

Parameters:

`numberToRound` the number to round up the number whose mutiple must be found

Returns:

the rounded number

Available since

1.0.0

.

• `Math.ceil`
• `Math.fceil`