Mail Archives: djgpp-workers/1998/11/17/09:25:22
>Hi Workers!
>
>Just a small question:
>
>Let's say I have a 32-bit unsigned integer, and I want to clear it's
>most significant bit. I wrote this code:
>
> (x*2)/2
>
>And of course(?) it doesn't work. Is it a bug in gcc or a bug in me?
>
This seems to be a feature: Even if I did not optimize this code (gcc t.c),
the compiler
removes the *2/2 operation. For disabling the optimization, use the
following construct:
y = 2;
x = (x*y)/2;
This code work in all cases. However, why didn't you use
x & 0x7FFFFFFF ???
--
Michael Beck, email: beck AT dresearch DOT de
DResearch GmbH, D-10319 Berlin, Otto-Schmirgal-Strasse 3
Fon.: +49 (030) 515932 224 Fax.: +49 (030) 515932 299
- Raw text -