RSS Forums RSS
Please support our C advertiser: Programming Forums
Views: 1339 | Replies: 2 | Thread Tools  Display Modes
Reply
Join Date: Aug 2005
Posts: 596
Reputation: SpS is on a distinguished road 
Rep Power: 5
Solved Threads: 31
SpS's Avatar
SpS SpS is offline Offline
Posting Pro

Solution << shift and >> shift

  #1  
Sep 6th, 2005
Is there any sequence of left shift and right shift operators that can divide or multiply a number by a number that is not a multiple of 2 i.e. can we multiply a number by 11 using a sequence of left shift and right shift operators .
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2004
Posts: 3,809
Reputation: Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light Dave Sinkula is a glorious beacon of light 
Rep Power: 17
Solved Threads: 147
Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: << shift and >> shift

  #2  
Sep 6th, 2005
Yes, you can simulate multiplication by non-powers-of-two with shifting and adding. For example, 11 = 8 + 2 + 1, you can build up from that.
High Plains Blogger #plains #lounge ## I, for one, welcome our new socialist overlords.
"Capitalism is the unequal distribution of wealth. Socialism is the equal distribution of poverty."
Reply With Quote  
Join Date: Aug 2005
Posts: 596
Reputation: SpS is on a distinguished road 
Rep Power: 5
Solved Threads: 31
SpS's Avatar
SpS SpS is offline Offline
Posting Pro

Re: << shift and >> shift

  #3  
Sep 6th, 2005
thanx alot....that was pretty fast reply
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the C Forum
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 6:25 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC