On 25/7/03 2:18 am (UK time), Roy Smith let loose these words:
> (yvan joffre) wrote:
>
>>Why do not write just this:
>>
>>unsigned int SeqDiv7(unsigned int val) {
>> unsigned int v=val, result=0;
>> while(v > 0) {
>> v >>= 3;
>> result += v;
>> }
>> return result;
>>}
>
>
> Why the intermediate variable v? Why not just use val directly in the
> body of the function?
Not sure. Guess that to me, val means what was actually passed into the
function, rather than some modification of it.
Speaking of which, do most compilers tend to generate the same code
either way? (g++ 3.1 (Mac OS X) is giving me the exact same except for
one byte, and they seem to take the same amount of time.)
Stewart.
--
My e-mail is valid but not my primary mailbox. Please keep replies on
on the 'group where everyone may benefit.