Consider the following code:
for (float i = 0f; i < int.MaxValue; i++)
{
// Some code
}
Which is supposed to loop from 0
to int.MaxValue
(231-1), but it doesn't. Once i
reached 224, i++
doesn't work anymore for a reason that I'm totally unable to understand.
In the Immediate Window of VS I've try this:
>i
16777216.0
>i + 1
16777216.0 // ???
>i == i + 1
false // as expected, but a lack of consistency with upper statement
>i + 2
16777218.0
Why does it behave like so? What is special with 224+1?