Difference between revisions of "Round"

From MiniScript Wiki
Jump to navigation Jump to search
(See also: floor - formatting)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<c>round</c> rounds a number to the specified number of decimal places.
 
<c>round</c> rounds a number to the specified number of decimal places.
  
 +
See also: [[floor]], [[ceil]]
  
 
=== Arguments ===
 
=== Arguments ===
Line 8: Line 9:
 
! Parameter Name !! Default Value !! Meaning
 
! Parameter Name !! Default Value !! Meaning
 
|-
 
|-
| ''x'' || number || number to round
+
| ''x'' || 0 || number to round
 +
|-
 +
| ''decimalPlaces'' || 0 || number of decimal places to round to (may be negative)
 
|}
 
|}
 
=== Usage Notes ===
 
<c>round</c> may be called either as a global method, passing the sequence or map as an argument; or as a member function (defined on [[list]], [[string]], and [[map]]) using [[dot syntax]], with no arguments.
 
  
 
== Examples ==
 
== Examples ==
Line 18: Line 18:
 
<ms>round(pi, 2)            // returns 3.14
 
<ms>round(pi, 2)            // returns 3.14
 
round(12345, -3)        // returns 12000</ms>
 
round(12345, -3)        // returns 12000</ms>
 
== See also ==
 
 
* [[floor]]
 
 
  
 
[[Category:Intrinsic Functions]]
 
[[Category:Intrinsic Functions]]
 
[[Category:Numeric Functions]]
 
[[Category:Numeric Functions]]

Latest revision as of 15:14, 25 March 2022

round rounds a number to the specified number of decimal places.

See also: floor, ceil

Arguments

Parameter Name Default Value Meaning
x 0 number to round
decimalPlaces 0 number of decimal places to round to (may be negative)

Examples

round(pi, 2)             // returns 3.14
round(12345, -3)         // returns 12000