C # Double indicates the number of digits after the decimal point.

Source: Internet
Author: User

Double test1 = 1000.0;
Double Test2 = 1000.12345;
Double test3 = 1000.1289;
Int Test 4 = 1000;
String test5 = "1000 ";
String test6 = "1000.12345 ";
String test7 = "1000.1289"

Convert. todouble (test1). tostring ("0.00"); // retain the last two digits of the decimal point. The result is 1000.00.
Convert. todouble (Test2). tostring ("0.00"); // retain the last two digits of the decimal point. The result is 1000.12.
Convert. todouble (test3). tostring ("0.00"); // retain the last two digits of the decimal point. The result is 1000.13.
Convert. todouble (test4). tostring ("0.00"); // retain the last two digits of the decimal point. The result is 1000.00.
Convert. todouble (test5). tostring ("0.00"); // retain the last two digits of the decimal point. The result is 1000.00.
Convert. todouble (test6). tostring ("0.00"); // retain the last two digits of the decimal point. The result is 1000.12.
Convert. todouble (test7). tostring ("0.00"); // retain the last two digits of the decimal point. The result is 1000.13.

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.