delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/28/21:29:21

To: djgpp AT delorie DOT com
Subject: Re: fixed point math: NEED HELP QUICK!
Message-ID: <19970128.181621.14527.2.chambersb@juno.com>
References: <199701290130 DOT UAA02417 AT delorie DOT com>
From: chambersb AT juno DOT com (Benjamin D Chambers)
Date: Tue, 28 Jan 1997 21:15:30 EST

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019