Round (Float function): Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
mNo edit summary |
||
Line 1: | Line 1: | ||
{{Template:Float:Round subtitle}} | {{Template:Float:Round subtitle}} | ||
The <var>Round</ | The <var>Round</var> [[Intrinsic classes|intrinsic]] function returns a floating point number that is the method object number rounded to a specified number of decimal places. | ||
==Syntax== | ==Syntax== | ||
{{Template:Float:Round syntax}} | {{Template:Float:Round syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%number</th> | <tr><th>%number</th> | ||
<td>A variable to receive the floating point result. </td></tr> | <td>A variable to receive the floating point result. </td></tr> | ||
<tr><th>float</th> | <tr><th>float</th> | ||
<td>A <var>Float</var> value to be rounded to the number of decimal places specified in the method argument, <var class="term">dp</var>. </td></tr> | <td>A <var>Float</var> value to be rounded to the number of decimal places specified in the method argument, <var class="term">dp</var>. </td></tr> | ||
<tr><th>dp</th> | <tr><th>dp</th> | ||
<td>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.</td></tr> | <td>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.</td></tr> | ||
Line 16: | Line 19: | ||
==Usage notes== | ==Usage notes== | ||
<ul><li>Negative numbers are rounded down to the nearest integer; positive numbers are rounded up. | <ul> | ||
<li><var>Round</var> is available as of <var class="product"> | <li>Negative numbers are rounded down to the nearest integer; positive numbers are rounded up. | ||
<li><var>Round</var> is available as of <var class="product">Sirius Mods</var> Version 7.6. | |||
</ul> | |||
==Examples== | ==Examples== | ||
The following program demonstrates the <var>Round</var> method. | |||
<p class="code">begin | <p class="code">begin | ||
[[PrintText statement|printText]] {~} = {3.1415926:round} | [[PrintText statement|printText]] {~} = {3.1415926:round} | ||
Line 33: | Line 38: | ||
3.1415926:round(1) = 3.1 | 3.1415926:round(1) = 3.1 | ||
3.1415926:round(4) = 3.1416 | 3.1415926:round(4) = 3.1416 | ||
</p | </p> | ||
==See also== | ==See also== | ||
{{Template:Float:Round footer}} | {{Template:Float:Round footer}} |
Revision as of 18:06, 2 November 2012
Round a floating point number to specified decimal places (Float class)
The Round intrinsic function returns a floating point number that is the method object number rounded to a specified number of decimal places.
Syntax
%number = float:Round[( [dp])]
Syntax terms
%number | A variable to receive the floating point result. |
---|---|
float | 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.
- Round is available as of Sirius Mods Version 7.6.
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