Mail Archives: djgpp/1997/01/28/21:29:21
On Tue, 28 Jan 1997 20:30:34 -0500 DJ Delorie <dj AT delorie DOT com> writes:
>
>> function. Anyway, here's my problem; To my understanding the
>following
>> are 100% equal:
>>
>> other_stuff = stuff / 256;
>> other_stuff = stuff << 8;
>
>The second multiplies. Try ">> 8" instead.
>
>
Also, just to be clear, the first gets translated into the second when
compiling with optimizations on (-O2).
In fact, I believe *ALL* integer multiplication/division by a constant
gets converted to shifts when using -O2, so you might as well use the
first - if for nothing else then for readability's sake.
...Chambers
- Raw text -