Round Procedure

Version 5

Returns the number x rounded to a specified number of digits, lDigits, either round-off decimal digits or round-off whole number if lDigits > 0.  If omitted, returns the nearest integer number of dx.

Syntax

[ dResult = ] Round ( dx, [lDigits] )

The Round procedure syntax has the following parts:

 

Name

Type

Description

dResult

Double

Result

dx

Val Double

Input Value

lDigits

[Val] Long

Optional digits:

[0]  - default value

> 0 - round-off whole number

< 0 - round-off decimal digits

Comments

 

Example

 

print "-- Round(2.8) => "; Round(2.8)

print "-- Round(-2.8) => "; Round(-2.8)

print "-- Round(3.5) => "; Round(3.5)

print "-- Round(-3.5) => "; Round(-3.5)

print "-- Round(4.4999999999) => "; Round(4.4999999999)

print "-- Round(-4.4999999999) => "; Round(-4.4999999999)

!

print "-- Round(-1234.1962, 3) => "; Round(-1234.1962, 3)

print "-- Round(-1274.1962, 2) => "; Round(-1274.1962, 2)

print "-- Round(-1234.1962, -3) => "; Round(-1234.1962, -3)

print "-- Round(-1274.1962, -2) => "; Round(-1274.1962, -2)

 

! the following is the results of each print statement:

-- Round(2.8) => 3

-- Round(-2.8) => -3

-- Round(3.5) => 4

-- Round(-3.5) => -4

-- Round(4.4999999999) => 4

-- Round(-4.4999999999) => -4

-- Round(-1234.1962, 3) => -1000

-- Round(-1274.1962, 2) => -1300

-- Round(-1234.1962, -3) => -1234.196

-- Round(-1274.1962, -2) => -1274.2

See Also

Int