Round (Float function)

From m204wiki
Revision as of 05:45, 4 February 2011 by Goff (talk | contribs) (match syntax diagram to template; fix tags and links)
Jump to navigation Jump to search

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, number.
number 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

  1. 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