Executed in c# interactive
> 200M.ToString()
"200"
> 200.0M.ToString()
"200.0"
> 200.000000000000M.ToString()
"200.000000000000"
I was mind blown by this. Why this happens?
Executed in c# interactive
> 200M.ToString()
"200"
> 200.0M.ToString()
"200.0"
> 200.000000000000M.ToString()
"200.000000000000"
I was mind blown by this. Why this happens?
200 and 200.0 are the same numerically (200m == 200.0m
returns true
), of course, but "200"
and "200.0"
are certainly not the same string, and certainly will not pass a string.Equals()
check
Decimal class always retains things like precision and scale. Decimal is intended for monetary calculations, so we definitely want it to exhibit this sort of meticulous behavior