All Functions
Fix Function
Int Function
FUNCTION: Round( )
Round
(Number,
NumDecimalPlaces
)
The
Round
function rounds off a floating-point number (decimal) to a specified number of decimal places.
There is one mandatory argument.
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
Even numbers that are composed of the exact decimal .5, such as 2.5, 4.50, or 22.500000, are rounded down (towards the negative direction).
Negative, even numbers are rounded up (towards the postive direction).
Odd number that are composed of the exact decimal .5, such as 1.5, 3.50, or 21.500000, are rounded up (towards the positive direction).
Negative, odd numbers are rounded down (towards the negative direction).
Code:
<% =Round(4.50) %>
<% =Round(3.5) %>
<% =Round(2.5000) %>
<% =Round(1.5) %>
<% =Round(0.50000) %>
<% =Round(-0.50) %>
<% =Round(-1.5) %>
<% =Round(-2.50000000) %>
<% =Round(-3.5) %>
<% =Round(-4.5) %>
Output:
4
4
2
2
0
0
-2
-2
-4
-4
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
Copyright 1999-2004 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information