ASP has two functions that can be used as rounding functions: the round function and the formatnumber function.
Round Function
Returns the value rounded to the specified number of digits.
Round (expression [, numdecimalplaces])
Parameters
Expression
Required. The numeric expression is rounded down.
Numdecimalplaces
Optional. Number indicates the number of digits to the right of the decimal point. If this parameter is omitted, the round function returns an integer.
Formatnumber Function
Formatnumber (expression [, digit [, leadingdigit [, Paren [, groupdigit].
Parameters
Expression
Required.
Digit indicates the number of digits displayed on the right of the decimal point. The default value is-1, indicating that the computer's regional settings are used.
Leadingdigit indicates the number of digits displayed on the right of the decimal point. The default value is-1, indicating that the computer's regional settings are used.
Paren indicates the number of digits to the right of the decimal point. The default value is-1, indicating that the computer's regional settings are used.
Groupdigit indicates the number of digits to the right of the decimal point. The default value is-1, indicating that the computer's regional settings are used.
Example
Example: <% = round (3.14159, 2) %>
Result: 3.14
Example: <% = formatnumber (45.324567, 3) %>
Result: 45.325
Differences
Although the round function is called a rounding function, what he calls rounding is not the same as what we usually call it. What we usually say is: a number greater than or equal to 5 is included and a value less than 5. However, the round function is an integer greater than 5, a value less than 5, and an odd number into an even number if the value is 5.
Example
Round (1.5)
Round (2.5)
Round (3.5)
Round (4.5)
Formatnumber (1.5, 0)
Formatnumber (2.5, 0)
Formatnumber (3.5, 0)
Formatnumber (4.5, 0)
The result of round is:
2
2
4
4
The result of formatnumber is:
2
3
4
5
It seems that if you really want to use the rounding function, it is more accurate to use the formatnumber!