Math - MSUTeam/MSU GitHub Wiki

File path: scripts/config/msu/math.nut

log2int

::MSU.Math.log2int( _num );
// _num is a float or integer

Returns the base 2 logarithm of _num floored as an int.

normalDist

::MSU.Math.normalDist( _x, _mean, _std )
// _x, _mean and _std are floats or integers

Returns the value of the Normal Distribution for _x for the provided mean value of _mean and standard deviation _std.

normalDistNorm

::MSU.Math.normalDistNorm( _x, _mean, _std )
// _x, _mean and _std are floats or integers

Returns the normalized (divide by maximum) value of the Normal Distribution for _x for the provided mean value of _mean and standard deviation _std.

randf

::MSU.Math.randf( _min, _max )
// _min and _max are floats

Returns a random float between _min and _max, inclusive of both.

roundToMult

::MSU.Math.roundToMult( _num, _multiple )
// _num and _multiplier are integers or floats
// _multiplier cannot be negative

Returns a float which is _num rounded to the nearest multiple of _multiple.

roundToSig

::MSU.Math.roundToSig( _num, _significantFigures )
// _num is an integer or float
// _significantFigures is a positive integer

Returns a float which is _num rounded to _significantFigures significant figures.

roundToDec

::MSU.Math.roundToDec( _num, _decimalPlaces )
// _num is an integer or float
// _decimalPlaces is a positive integer

Returns a float which is _num rounded to _decimalPlaces decimal places.

truncf

::MSU.Math.truncf( _num, _decimalPlaces )
// _num is a float
// _decimalPlaces is a positive integer

Returns a float which is _num with any decimal places beyond _decimalPlaces removed.

⚠️ **GitHub.com Fallback** ⚠️