wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> cs >> MULTIPLY WITHOUT MULTIPLYING
(Message started by: eviljed on Aug 9th, 2002, 10:50am)

Title: MULTIPLY WITHOUT MULTIPLYING
Post by eviljed on Aug 9th, 2002, 10:50am
Multiply by 8 without using multiplication or addition. Now do the same with 7.

For 8:  Convert to binary.  Shift left twice.  That'll do it. (note that the shifts put zeros in the least significat values).

For 7:  I'll have to get back to you on that.

Title: Re: MULTIPLY WITHOUT MULTIPLYING
Post by eviljed on Aug 9th, 2002, 11:02am
I just had an ID-10T error. (aka, i'm an idiot).  You shift to the left three times.  Two shifts only multiplies it by 4.

Title: Re: MULTIPLY WITHOUT MULTIPLYING
Post by Aaron on Aug 9th, 2002, 11:54am
I am assuming that addition and subtraction are different functions here...

n = (n << 3) - n;

I am still fiddling with the bits for a solution that involves no arithmatics, short of going all the way to implementing a binary subtraction function with logigates.   :P

Title: Re: MULTIPLY WITHOUT MULTIPLYING
Post by -D- on Aug 9th, 2002, 4:27pm
There is a long thread on this already furthur down the page with several ideas on it.
-D-



Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board