Unsigned int fun

Hi there,

I was doing a common task today involving incrementing and decrementing an array index. I found something interesting. I would like to know more about what is happening exactly. Here’s a sample reproducing the “issue”:


var i:uint = 0;
if(--i > 0) {
    i = 0;
    trace("Was processed before the condition check. i =", i);
} else {
    trace("Was processed after the condition check. i =", i);
}

And the console says:


Was processed after the condition check. i = 4294967295

At first I thought that index i would be decremented before the condition i > 0, but this isn’t the case here. Any explanations? I know why the value is now 4294967295, but I’m not certain why that value wasn’t assigned to i before the condition was made.

Thank you.