Tech Support > Computers & Technology > Programming > puzzle little closer to machine.
puzzle little closer to machine.
Posted by unknown@this-world.com on July 3rd, 2005


Can somebody solve the following puzzle ?

Suppose I have a 32 bit machine with 32 bit 32 registers.
How to multiply two integers in such a machine with taking
care of all the overflows. Also MUL or such multiplication
operands are not available in such a machine.

Good Luck!

Posted by osmium on July 3rd, 2005


<unknown@this-world.com> wrote:

The thing you call a puzzle sounds more like a school assignment. You
wouldn't try to con us, would you?



Posted by unknown@this-world.com on July 4th, 2005


hah! way back I passed those wonderful school days, and I
luved to solve those school assignments. Its just the job or
sometimes scratching my brain gets me puzzles like this.
Thought by putting this kinddaa puzzles I get to find ways
to do this, but ..... instead of solving u try to find the
origin of the problem ...huh

Thanks to those who give this a shot.. never mind otherwise.

osmium said the following on 07/03/2005 06:18 PM:

Posted by Jack Klein on July 4th, 2005


On Sun, 03 Jul 2005 12:33:52 GMT, unknown@this-world.com wrote in
comp.programming:

I don't need luck, I know how to do it. In fact, I've written 32 x 32
multiply routines that produced correct 64 bit results on 8 and 16 bit
machines.

The basic binary multiplication algorithm requires only shifts and
adds, and I assume your 32 bit processor provides both of those.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html

Posted by Gerry Quinn on July 4th, 2005


In article <QWQxe.7968$T77.1011@news.cpqcorp.net>, unknown@this-
world.com says...
Just long multiplication, which in binary means just shifts and adds.
In assembler there will normally be a carry flag set after a shift, so
you can tell when you have to add 1 to the 'high' refister before
shifting it.

- Gerry Quinn

Posted by CBFalconer on July 4th, 2005


Jack Klein wrote:
In addition, the 32*32 -> 64 multiplication can NEVER create an
overflow. Any possible problems arise later, when trying to stuff
a 64 bit entity into a 32 bit pot. If it doesn't fit you must act
on it.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson


Posted by pete on July 9th, 2005


unknown@this-world.com wrote:
Booth's Algorithm

http://jingwei.eng.hmc.edu/~rwang/e8...ml/node10.html

--
pete


Similar Posts