Utility functions for mathematical calculations.
1.0.0
.Static methods
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
1.0.0
.See also:
Math.floorMath.ffloor
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 |
|---|---|
nearest | the number whose mutiple must be found |
Returns:
the rounded number
1.0.0
.See also:
Math.roundMath.fround
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
1.0.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 |
|---|---|
nearest | the number whose mutiple must be found |
Returns:
the rounded number
1.0.0
.See also:
Math.ceilMath.fceil