This article is a mirror article of machine translation, please click here to jump to the original article.

View: 24140|Reply: 1

[Source] Functions that keep two decimal places after the decimal point in C# and how to use them

[Copy link]
Posted on 5/5/2018 7:23:52 PM | | |
Math.Round(45.367,2)     //Returns   45.37
Math.Round(45.365,2)     //Returns   45.36

Round() in C# is not rounding as we Chinese understand, it is rounding for foreigners, it is rounding in line with IEEE standards, specifically rounding, and the following is the rounding in line with the Chinese understanding

Math.Round(45.367,2,MidpointRounding.AwayFromZero); //45.37

Math.Round(45.365,2,MidpointRounding.AwayFromZero)     //Returns   45.37   





Previous:.net/C# Distributed TransactionScope
Next:.net/c# get all Chinese characters and all pinyin [source code]
Posted on 5/7/2018 2:23:15 PM |
Our company has caused incorrect amounts due to this problem before, which almost caused losses to the company
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com