Invert GMLscripts.com

round_fixed

Returns a given number rounded to the a number of places. If places is positive, the number is rounded on the right side of the decimal separator. If places is negative, the rounding occurs on the left side of the decimal separator.

n = round_fixed(2468.1357,  2); //  n == 2468.14
n = round_fixed(2468.1357, -2); //  n == 2500.00
round_fixed(number, places)
Returns a given number rounded to the a number of places.
COPY/// @func   round_fixed(number, places)
///
/// @desc   Returns a given number rounded to the a number of places.
///         If places is positive, the number is rounded on the right
///         side of the decimal separator. If places is negative, the
///         rounding occurs on the left side of the decimal separator.
///
///         eg. round_fixed(2468.1357,  2) == 2468.14
///             round_fixed(2468.1357, -2) == 2500.00
///
/// @param  {real}      number      number to round
/// @param  {real}      places      decimal places to round to
///
/// @return {real}      rounded number
///
/// GMLscripts.com/license

function round_fixed(number, places)
{
    return round(number * power(10, places)) / power(10, places);
}

Contributors: IceMetalPunk

GitHub: View · Commits · Blame · Raw