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

View: 17670|Reply: 0

[Source] C# rounds the double

[Copy link]
Posted on 2/22/2016 3:13:02 PM | | |

When the integer part of the double is too large, such as 12233445455566777888.87866, the integer obtained will be a negative number because the integer part of the double exceeds the int value range

The right way:
1.   string vv = dd.ToString("f0");
     double dd2 = Convert.ToDouble(vv);
2.   double dd2= Math.Floor(dd);



The first method is also problematic,
dd=1.6461153328323031E+18;

string vv = dd.ToString("f0");   ---"1646115332832300000"  
double dd2 = Convert.ToDouble(vv); ---1.6461153328323E+18         

double dd1 = Math.Floor(dd); ---1.6461153328323031E+18




Previous:The difference between mysql_unbuffered_query and mysql_query in PHP
Next:C# Form-to-Form Values (Using Delegates vs. Custom Events)
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