TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ERIC YALE
from: ERIK WARMELINK
date: 1997-04-09 18:57:00
subject: Re: Video

Eric Yale wrote in a message to nobody:
 EY>         It is almost always faster to do a shift because of the 
 EY> fact that that given a n-binary number shifting to the left by 
 EY> one bit is the same as multiplying by 2.
Not really a convincing argument, I could also say:
``It is almost always faster to do a multiplication because of the fact that 
that given a n-binary number multiplying by 2 is the same as shifting to the 
left by one bit.'', which is also false.
It depends on the speed of a multiplication vs. the speed of a shift. Your 
compiler will know more about the speed of the computer you're compiling to, 
give the poor thing a chance to produce fast code by writing obvious and 
clear code. It is easy for a compiler to replace ``x*320'' by 
``(x<<6)+(x<<8)'' or ``(x+(x<<2))<<6'' -- if the number of shifts is 
important. It is much harder to see that ``(x<<6)+(x<<8)'' can be replaced by 
``x*320'', even the latter would be faster.
Bye,
 Erik 
---
---------------
* Origin: WarmelinkE@vertis.nl (2:282/608.60)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.