Subj : Re: puzzle little closer to machine. To : comp.programming From : Jack Klein Date : Mon Jul 04 2005 02:47 am On Sun, 03 Jul 2005 12:33:52 GMT, unknown@this-world.com wrote in comp.programming: > 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! 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/~ajo/docs/FAQ-acllc.html .