I was playing with decimal today. I noticed this:
Decimal.MaxValue
79228162514264337593543950335
Decimal.MaxValue - 0.5m
79228162514264337593543950334
The following code prints true.
static void Main(string[] args)
{
decimal d = Decimal.MaxValue - 0.5M;
var b = d % 1 == 0;
Console.WriteLine(b);
}
I am sure there is a reason behind this but I don't know what it is.