Now what is the difference between i and j?
i
has 6 decimal places of precision; j
only has 2. Sure, the difference doesn't change the magnitude of the number at all - and i == j
will still return true
- but decimal
retains the number of decimal places, and presumably your web service client code notices that you're specifying more than will be preserved.
From the documentation:
The scaling factor also preserves any trailing zeros in a Decimal number. Trailing zeros do not affect the value of a Decimal number in arithmetic or comparison operations. However, trailing zeros might be revealed by the ToString method if an appropriate format string is applied.
This is one of the significant differences between decimal
and float
/double
in .NET.