Core Function Round
From Sputnik Wiki
(Difference between revisions)
UberFoX (Talk | contribs)
(Created page with "<pre> Round( <expression>, <decimalplaces> ) </pre> === Description === Returns a number rounded to a specified number of decimal places. === Parameters === ==== expression =...")
(Created page with "<pre> Round( <expression>, <decimalplaces> ) </pre> === Description === Returns a number rounded to a specified number of decimal places. === Parameters === ==== expression =...")
Latest revision as of 19:01, 2 December 2011
Round( <expression>, <decimalplaces> )
Contents |
Description
Returns a number rounded to a specified number of decimal places.
Parameters
expression
Any valid numeric expression.
newbase
Optional; Number indicating how many places to the right of the decimal are included in the rounding. If omitted, Round returns an integer.
Return Value
Returns rounded number.
Remarks
The decimalplaces parameter can be negative which allows you to round to the ones, tens, hundred, etc. place.
Note that up to fifteen digits of a number are displayed, and note that decimalplaces will never pad a number with trailing zeros.
Example
$x = Round(-1.582, 1); //returns -1.6 $y = Round(3.1415, 9); //no change $z = Round(123.5, -1); //returns 120 println("X: $x Y: $y Z:$z");