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

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -