c# - String to double with 0 tail -
this question has answer here:
- formatting doubles output in c# 10 answers
- storing double 2 digit precision 4 answers
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
Post a Comment