This is because double
is a floating point datatype.
If you want greater accuracy you could switch to using decimal
instead.
The literal suffix for decimal
is m, so to use decimal
arithmetic (and produce a decimal
result) you could write your code as
var num = (3600.2m - 3600.0m);
Note that there are disadvantages to using a decimal
. It is a 128 bit datatype as opposed to 64 bit which is the size of a double
. This makes it more expensive both in terms of memory and processing. It also has a much smaller range than double
.