473,405 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to multiple two values with out *

190 100+
Hi,

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

Is there any way....
Aug 11 '08 #1
11 1240
Savage
1,764 Expert 1GB
5*3=3+3+3+3+3

Does this lightens the bulb for you?

Regards.
Aug 11 '08 #2
maheswaran
190 100+
No not like that...

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

May like this help

MUL(5,3)
Aug 11 '08 #3
JosAH
11,448 Expert 8TB
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
Aug 11 '08 #4
whodgson
542 512MB
How about:
mult(x,y)=alog(log(x)+log(y))
or
prod=0;
for(i=0;i<5;i++)
prod+=3;
Aug 18 '08 #5
ashitpro
542 Expert 512MB
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 )
Aug 18 '08 #6
rajujrk
107 100+
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 ...
Aug 18 '08 #7
Banfa
9,065 Expert Mod 8TB
Put the text "what is 3 times 5" in a string, add it to the string "http://www.google.co.uk/search?q=" converting spaces to + to give "http://www.google.co.uk/search?q=what+is+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.
Aug 18 '08 #8
JosAH
11,448 Expert 8TB
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 ;-)
Aug 18 '08 #9
Banfa
9,065 Expert Mod 8TB
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" :-)
Aug 18 '08 #10
leejwen
50
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.
Aug 18 '08 #11
sicarie
4,677 Expert Mod 4TB
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
Aug 18 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: scott | last post by:
Hi, I'm having some trouble with something that should be relatively easy. I want to update multiple rows in one of my database tables simultaneously. In my table I have these values: ...
66
by: Darren Dale | last post by:
Hello, def test(data): i = ? This is the line I have trouble with if i==1: return data else: return data a,b,c,d = test()
3
by: jason | last post by:
How does one loop through the contents of a form complicated by dynamic construction of checkboxes which are assigned a 'model' and 'listingID' to the NAME field on the fly in this syntax:...
10
by: shank | last post by:
I have a recordset that contains multiple records of product a user is purchasing. For clarity, I converted the recordset fields to variables. I need to take that entire recordset and insert it...
1
by: John Smith | last post by:
I have a user assigned multiple roles and a role can be inherited from multiple parents (see below). How do I answer such questions as "How many roles does the user belongs to?" I answered the...
4
by: cwwilly | last post by:
Hello, Thanks for taking a look at this! Problem: I'm trying to pass multiple dynamic values between a slaveform and a masterform. The problem I'm having is on the slaveform I loop through...
3
by: rhamlin | last post by:
I'm fairly new to creating complex sql statements and need a little help. In plain english I want to do this: Select menu rows where the row's userGroupIDs equal the user's userGroupIDs. ...
16
by: Nikolay Petrov | last post by:
How can I return multiple values from a custom function? TIA
10
by: ads | last post by:
hi, after binding the dropdownlist to a datasource, ive experience this error "Cannot have multiple items selected in a dropdownlist" after using the code:...
8
by: aleksandar.ristovski | last post by:
Hello all, I have been thinking about a possible extension to C/C++ syntax. The current syntax allows declaring a function that returns a value: int foo(); however, if I were to return...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.