Thread: Multiply using Bitwise

  1. #1
    C is Sea. I know a drop! ganesh bala's Avatar
    Join Date
    Jan 2009
    Location
    Bangalore
    Posts
    58

    Question Multiply using Bitwise

    How to write a program

    Code:
     to Perform Multiply of 2 integers using Bitwise Operator
    ?

    If u know,Share The Logic Plz....

  2. #2
    C is Sea. I know a drop! ganesh bala's Avatar
    Join Date
    Jan 2009
    Location
    Bangalore
    Posts
    58
    Share Other than Repeated Addition Logic

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Search the Web for "bitwise multiplication"? Personally, I will not bother since a * b is likely to be no worse than anything you can implement yourself via bitwise operators. On the other hand, if you are talking about specific cases, then things like a bitwise left shift can come in handy... but an optimising compiler may perform such an optimisation for you anyway.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by ganesh bala View Post
    Share Other than Repeated Addition Logic
    You'll be embarrassed if I tell you!

    Think about base 10 (normal number system). If you multiply times the base, it's the same as adding a zero to the right hand side of the number: 12 * 10 = 120.

    That's true with any base numbering system, even binary (base 2).

    We can't add a number to the right, exactly, but we can do the same thing by pulling the current digits of the number...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bitwise Questions
    By someprogr in forum C Programming
    Replies: 8
    Last Post: 12-14-2008, 06:45 PM
  2. multiply link list
    By mradul.exe in forum C Programming
    Replies: 5
    Last Post: 07-12-2008, 07:18 PM
  3. bitwise operations with double
    By henry_kay in forum C Programming
    Replies: 2
    Last Post: 10-03-2007, 04:57 AM
  4. Characters into bitwise ints
    By Code Zer0 in forum C++ Programming
    Replies: 9
    Last Post: 04-24-2003, 08:34 AM
  5. Replies: 5
    Last Post: 10-30-2002, 10:23 PM