ÄúµÄλÖãºÑ°ÃÎÍøÊ×Ò³£¾±à³ÌÀÖÔ°£¾VBScript£¾VBScript


objects constants operators statements functions properties methods






FUNCTION:  Round( )

Round(Number, NumDecimalPlaces)

The Round function rounds off a floating-point number (decimal) to a specified number of decimal places.

One argument is mandatory.

Number

The Number argument is the number you wish to round off.

If the number of decimal places to round off to is not specified, the number is rounded off to an integer.

Code:
<% =Round(1.123456789) %>

Output:
1

Code:
<% =Round(9.87654321) %>

Output:
10

Note that negative numbers are rounded down (more negative).

Code:
<% =Round(-2.899999999) %>

Output:
-3


There is one optional argument

NumDecimalPlaces

The optional NumDecimalPlaces argument specifies how many decimal places to round off to.

Code:
<% =Round(1.123456789, 6) %>

Output:
1.123457

Note that negative numbers are rounded down (more negative).

Code:
<% =Round(-2.899999999, 2) %>

Output:
-2.9