简体   繁体   中英

string to double skips last decimal if it is zero?

Here is my Problem.

I need to Convert say "5.550" (string) to double as 5.550 that is double with 3 decimal digits. i have tried IFormatProvider while parsing but no use.it keeps skipping last zero(). Please advice.

Thanks, Kumar MA

double doesn't keep insignificant digits - there's no difference between 1.5 and 1.50000 as far as double is concerned.

If you want to preserve insignificant digits, use decimal instead. It may well be more appropriate for you anyway, depending on your exact context. (We have very little context to go on here...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM