Round: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
''This function is for BASIC compatibility. It is not available in pure JavaScript projects.'' | |||
Round(''number''[, ''fractionaldigits'']) | Round(''number''[, ''fractionaldigits'']) | ||
== Description == | == Description == | ||
Round returns a number that has been rounded to the specified number of decimal places. The required argument, ''number'', is any valid numeric expression. The optional argument, ''fractionaldigits'', is the number of decimal places included in the rounding; if ''fractionaldigits'' is not provided it defaults to 0 and | Round returns a number that has been rounded to the specified number of decimal places. The required argument, ''number'', is any valid numeric expression. The optional argument, ''fractionaldigits'', is the number of decimal places included in the rounding; if ''fractionaldigits'' is not provided it defaults to 0 and Round returns integers. | ||
== Example == | == Example (Basic) == | ||
<pre> | <pre> | ||
Line 11: | Line 13: | ||
'Round rounds numbers to a given decimal place | 'Round rounds numbers to a given decimal place | ||
Dim Pi, Pure, Ate | Dim Pi, Pure, Ate | ||
Pi = | Pi = Round(3.14159265, 4) | ||
Print Pi | Print Pi | ||
Pure = Round(99.4444, 2) | Pure = Round(99.4444, 2) | ||
Line 29: | Line 31: | ||
== Related Items == | == Related Items == | ||
[[int| | [[int|Int]], [[fix|Fix]] | ||
[[Category:Language Reference]] | [[Category:Language Reference]] | ||
[[Category:Math]] | |||
[[Category:BASIC Functions]] |
Latest revision as of 15:33, 25 March 2019
This function is for BASIC compatibility. It is not available in pure JavaScript projects.
Round(number[, fractionaldigits])
Description
Round returns a number that has been rounded to the specified number of decimal places. The required argument, number, is any valid numeric expression. The optional argument, fractionaldigits, is the number of decimal places included in the rounding; if fractionaldigits is not provided it defaults to 0 and Round returns integers.
Example (Basic)
Rem Round Example 'Round rounds numbers to a given decimal place Dim Pi, Pure, Ate Pi = Round(3.14159265, 4) Print Pi Pure = Round(99.4444, 2) Print Pure Ate = Round(Sqr(69)) Print Ate
Output
3.1416 99.44 8