How to compare two decimals with 0 and 0.00

I have two decimal values. I want to compare those and want return false

decimal x =0;
decimal y= 0.00 or 0.0m;
i want show 
    if (x== y) // false 
or x.equals(y) // false
i tried many ways i could find solution.

1 answer

  • answered 2020-08-02 11:20 paxdiablo

    No, you need to understand that the value is distinct from the presentation.

    The values 0 and 0.00 (and 0e1 and 0.00000 and .0) are all zero, hence equal.

    If you want to distinguish them, you'll have to do something like storing them as strings, so the presentation is the value.