decimal to double
.net, c#
Solution
The value from that conversion is actually 0.050000000000000009714451465470119728706777095794677734375, as shown by DoubleConverter. That's the exact value of the nearest double to the decimal you converted.
When you use the debugger or normal string formatting, you aren't usually shown the exact result.
Problem
I have the following test code: ``` decimal test1 = 0.0500000000000000045656554454M; double test2 = (double)test1; ``` This results in test2 showing as 0.05 when debugging. Why is it being rounded to 2 decimal places? Thanks