Recently, using an ASP program to deal with some data forms, the problem of the number format, such as data retention of several decimal places, after research, you can use the ASP's built-in function FormatNumber to achieve, the following specifically said FormatNumber function use method.
FormatNumber function: Returns an expression formatted as a number.
Parameters:
Expression
Required option. The expression to format.
Numdigitsafterdecimal
Options available. Numeric value that indicates the number of digits displayed to the right of the decimal point. The default value is 1, which indicates the use of the computer's locale.
IncludeLeadingDigit
Options available. A three-state constant that indicates whether to display a leading zero for a decimal value. For specific values, see settings.
UseParensForNegativeNumbers
Options available. A three-state constant that indicates whether negative values are placed within parentheses. For specific values, see settings.
GroupDigits
Options available. A three-state constant that indicates whether numbers are grouped by using the group delimiter specified in the locale. For specific values, see settings.
Set up:
The IncludeLeadingDigit, useparensfornegativenumbers, and GroupDigits parameters have the following settings:
Constants Description
Tristate.true True
Tristate.false False
Tristate.usedefault your computer's locale
Exception/Error
Exception type error number condition
The InvalidCastException 13 type is not a number.
Note:
When one or more optional parameters are omitted, the value of the omitted parameter is provided by the locale setting.
Attention:
All settings information comes from the locale of the application. By default, this information is the locale set in Control Panel. However, you can make changes to it programmatically by using the. NET Framework.
To give a column:
Retains 2 decimal places: <%=formatnumber (123.12345,2)%> output: 123.12