How to multiple two values with out *

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maheswaran
    New Member
    • Mar 2007
    • 190

    How to multiple two values with out *

    Hi,

    I want to multiple tow values with out using * (i.e. 5*3=15)..

    Is there any way....
  • Savage
    Recognized Expert Top Contributor
    • Feb 2007
    • 1759

    #2
    5*3=3+3+3+3+3

    Does this lightens the bulb for you?

    Regards.

    Comment

    • maheswaran
      New Member
      • Mar 2007
      • 190

      #3
      No not like that...

      I do not know another way...so that i posted this one..

      May like this help

      MUL(5,3)

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by maheswaran
        Hi,

        I want to multiple tow values with out using * (i.e. 5*3=15)..

        Is there any way....
        The 'Russian peasants' method which is bit shifting and adding basically; e.g.

        5*3 (3 is odd so remember the left operand == 5)
        shift the left operand to the left and the right operand to the right
        10*1 (1 is odd so remember the left operand == 10)
        shift the left operand to the left and the right operand to the right
        20*0 (the right operand equals zero so add the remembered left operands:

        5+10 == 15.

        If the right operand is even don't remember the left operand but take the next step
        that shifts both operands.

        kind regards,

        Jos

        Comment

        • whodgson
          Contributor
          • Jan 2007
          • 542

          #5
          How about:
          mult(x,y)=alog( log(x)+log(y))
          or
          prod=0;
          for(i=0;i<5;i++ )
          prod+=3;

          Comment

          • ashitpro
            Recognized Expert Contributor
            • Aug 2007
            • 542

            #6
            Whenever you left shift the x number with y number, the value of x becomes x*(2^y). You can use this method for certain multiplications ...
            lets say you want to multiply 3*7
            3<<3 which becomes 3*(2^3) == 3*(8)...But you are supposed to multiply with 7 not 8..so just substract 3 from the answer..
            i.e.
            Ans = ( (3<<3) - 3 )

            Comment

            • rajujrk
              New Member
              • Aug 2008
              • 107

              #7
              Hai try the below

              c=a*b

              Instead of the above code use the below

              c=a/(1.0/b)

              Sure it will work..

              now u try it ...

              Comment

              • Banfa
                Recognized Expert Expert
                • Feb 2006
                • 9067

                #8
                Put the text "what is 3 times 5" in a string, add it to the string "http://www.google.co.u k/search?q=" converting spaces to + to give "http://www.google.co.u k/search?q=what+i s+3+times+5".

                Open a TCP socket on port 80 to www.google.com and using the appropriate headers request the URL string you have just created.

                Read back the results page returned by google.com and parse it for the answer, 15 by looking for the text "3 times 5".

                You can in fact use this method for a whole host of maths operations so I suggest that next time the revise the C/C++ standards they remove all the maths operators as they are clearly unrequired.

                Comment

                • JosAH
                  Recognized Expert MVP
                  • Mar 2007
                  • 11453

                  #9
                  Originally posted by Banfa
                  You can in fact use this method for a whole host of maths operations so I suggest that next time the revise the C/C++ standards they remove all the maths operators as they are clearly unrequired.
                  Pointy haired manager remark: "install a copy of that google on every machine
                  that has to be operational off line; here's a floppy disk"

                  kind regards,

                  Jos ;-)

                  Comment

                  • Banfa
                    Recognized Expert Expert
                    • Feb 2006
                    • 9067

                    #10
                    Originally posted by JosAH
                    Pointy haired manager remark: "install a copy of that google on every machine
                    that has to be operational off line; here's a floppy disk"
                    Geeky pale white, doesn't get to see the light of day engineer reply: "That isn't how it was specified" :-)

                    Comment

                    • leejwen
                      New Member
                      • Jun 2007
                      • 50

                      #11
                      1. Recommend a book,

                      Generic Programming and the STL - Using and Extending the C++ Standard Template Library.

                      You can write a Template which can deal with different types.

                      2. Train a feedforward neural network by using Matlab, which is a black box, you just need to pre-process and postprocess your input and output based on some data mining method, such as gaussion distribution, histgram etc.

                      Comment

                      • sicarie
                        Recognized Expert Specialist
                        • Nov 2006
                        • 4677

                        #12
                        Originally posted by leejwen
                        1. Recommend a book,

                        Generic Programming and the STL - Using and Extending the C++ Standard Template Library.

                        You can write a Template which can deal with different types.

                        2. Train a feedforward neural network by using Matlab, which is a black box, you just need to pre-process and postprocess your input and output based on some data mining method, such as gaussion distribution, histgram etc.
                        leejwen- please check your PM's, visible under the Network header at the top of the page
                        Last edited by sicarie; Aug 18 '08, 04:20 PM. Reason: Caught the sarcasm

                        Comment

                        Working...