Integer promotion... what I'm missing? (It's monday...)
Alexander Panek
alexander.panek at brainsware.org
Tue Jun 27 04:21:34 PDT 2006
If you take a look at how comparison works, you'll know why this one fails.
Lets take an uint a = 16; as in your example:
00000000 00000000 00000000 00010000
And now a signed integer with the value -1:
10000000 00000000 00000000 00000001
You might guess which number is bigger, when our comparison is done
binary (and after all, that's what the processor does) :)
Regards,
Alex
Paolo Invernizzi wrote:
> Hi all,
>
> What I'm missing?
>
> uint a = 16;
> int b = -1;
> assert( b < a ); // this fails! I was expecting that -1 < 16
>
> Thanks
>
> ---
> Paolo
More information about the Digitalmars-d-learn
mailing list