Round (Float function): Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (1 revision) |
||
Line 4: | Line 4: | ||
method object number rounded to a specified number of decimal places. | method object number rounded to a specified number of decimal places. | ||
The Round function is available as of version 7.6 of the <var class=product>Sirius Mods</var>. | The <var>Round</var> function is available as of version 7.6 of the <var class=product>Sirius Mods</var>. | ||
==Syntax== | ==Syntax== | ||
{{Template:Float:Round syntax}} | {{Template:Float:Round syntax}} | ||
Line 19: | Line 19: | ||
*Negative numbers are rounded down to the nearest integer; positive numbers are rounded up. | *Negative numbers are rounded down to the nearest integer; positive numbers are rounded up. | ||
==Examples== | ==Examples== | ||
The following program demonstrates the Round method. | The following program demonstrates the <var>Round</var> method. | ||
begin | begin | ||
[[PrintText statement|printText]] {~} = {3.1415926:round} | [[PrintText statement|printText]] {~} = {3.1415926:round} | ||
Line 42: | Line 42: | ||
<!-- | <!-- | ||
<section begin=dpl_desc /> | <section begin=dpl_desc /> | ||
Round a floating point value to the closest integer | <var>Round</var> a floating point value to the closest integer | ||
<section end=dpl_desc /> | <section end=dpl_desc /> | ||
--> | --> |
Revision as of 15:32, 19 January 2011
Round a floating point number to specified decimal places (Float class)
This intrinsic function returns a floating point number that is the
method object number rounded to a specified number of decimal places.
The Round function is available as of version 7.6 of the Sirius Mods.
Syntax
%number = float:Round[( [dp])]
Syntax terms
%num | A variable to receive the floating point result. |
---|---|
number | A Float value to be rounded to the number of decimal places specified in the method argument, dp. |
dp | A numeric value that specifies the number of decimal places to which the input number is rounded. This value defaults to 0, and it must be between 0 and 75. |
Usage notes
- Negative numbers are rounded down to the nearest integer; positive numbers are rounded up.
Examples
The following program demonstrates the Round method.
begin printText {~} = {3.1415926:round} printText {~} = {3.1415926:round(0)} printText {~} = {3.1415926:round(1)} printText {~} = {3.1415926:round(4)} end
The result is:
3.1415926:round = 3 3.1415926:round(0) = 3 3.1415926:round(1) = 3.1 3.1415926:round(4) = 3.1416
See also
List of intrinsic Float methods