ASP Rounding FormatNumber function usage

Source: Internet
Author: User
Tags locale

ASP inside the round function is said to be a single-minded rounding function, but the FormatNumber function can also achieve almost equivalent to rounding function, tested, formatnumber than round more accurate. The FormatNumber function is primarily used to format numbers, currencies, and percent data, such as converting 35569.5867 to 35569.59, so rounding it up is pretty good. Here's how to use the FormatNumber function.

FormatNumber (Expression [, Digit [, Leadingdigit [, Paren [, Groupdigit]]].

Parameter: expression is required.

Digit: Displays the number of digits to the right of the decimal point. The default value is-1, which indicates that the computer's locale is being used.

Leadingdigit: Displays the number of digits to the right of the decimal point. The default value is-1, which indicates that the computer's locale is being used.

Paren: Displays the number of digits to the right of the decimal point. The default value is-1, which indicates that the computer's locale is being used.

Groupdigit: Displays the number of digits to the right of the decimal point. The default value is-1, which indicates that the computer's locale is being used.

FormatNumber Usage Examples:

1. Keep Two decimal places:

Output Result: 3.14

2. Keep 3 decimal places:

Output Result: 45.325

Post language: The round function says rounding seems to be different from what we usually say, our usual is: is greater than or equal to 5 of the value, less than 5 of the value of the shed. But the round function is more than 5 of the value, less than 5 of the value of the house, equal to 5 of the odd number into even homes, so always feel a bit inconsistent with the habit, so still use the FormatNumber function bar. S

Note : Please pay attention to the Triple tutorial channel for more wonderful tutorials,

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.