c# - String to double with 0 tail -


this question has answer here:

i don't know how remove tail of 0 on "double" conversion generic currency string in c#.

this code

double reddito = math.round(convert.todouble("12500,245"), 3); 

the expected result

reddito = 12500.245 

the real result

reddito = 12500.245000000001 

what matter?

for currencies best use decimal type rather double. doubles , floats approximations of real number , can trouble financial calculations. recommended practice not test floats , doubles equality allow small tolerance around value particular reason.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -