Utility functions for mathematical calculations.

Available since

1.0.0

.

Static methods

@: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

nearest

the number whose mutiple must be found

Returns:

the rounded number

Available since

1.0.0

.

See:

Math.floor

@: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.

precision

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 down to the nearest 10, you will receive 20, and by rounding 26 down to the nearest 10, you will receive 40. Similar to the built-in function Math.ceil().

Parameters:

numberToRound

the number to round up

nearest

the number whose mutiple must be found

Returns:

the rounded number

Available since

1.0.0

.

See:

Math.ceil