Round - round a number

Return to Introduction  Previous page  Next page

$return = round(number[,precision][,TRIM])

Where:

 

$returnthe rounded number.
numberis a decimal number.        
precisionis the number of decimal places to include in the rounded result. If the precision specified is greater than the number of digits in the input, then trailing zeros will be added to the output.
TRIMtrims trailing zeros and trailing decimal point if nothing follows it after trimming zeros.        

 

number and precision may be variables.

 

The Round command rounds a number to the specified precision.

Examples

$result = round("3.1415",2)

 

Sample Script

' round pi

$pi = 3.1415

$a = round($pi)

$b = round($pi,1)

$c = round($pi,10)

MsgBox($a & $CRLF & $b & $CRLF & $c & $CRLF)

exit

 

See Also:

 

int

Script Command Summary

Script Variables

Using the Scripting Language


TN3270 Plus is continually being improved. To learn more about the latest enhancements, please review our Version History web page.