Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!mgnetp!ihnp4!mhuxl!ulysses!unc!mcnc!decvax!cca!ima!haddock!johna From: johna@haddock.UUCP Newsgroups: net.math Subject: Re: need fast algorithm for reciprocal - (nf) Message-ID: <195@haddock.UUCP> Date: Mon, 25-Jun-84 23:37:50 EDT Article-I.D.: haddock.195 Posted: Mon Jun 25 23:37:50 1984 Date-Received: Thu, 28-Jun-84 03:23:30 EDT Lines: 32 #R:burl:-48000:haddock:13000001:000:902 haddock!johna Jun 25 16:16:00 1984 The following is a division routine to divide 2 floating point numbers that have up to 31 bit mantissas. It uses only shifts, ORs, ANDs and subtraction. #define LO31BITS 0x7fffffff #define BIT0 0x1 divide(dividend, divisor, quotient, sign_dvd, sign_dvi, sign_quo, exp_dvd, exp_dvi, exp_quo) long dividend, divisor, quotient, sign_dvd, sign_dvi, sign_quo; long exp_dvd, exp_dvi, exp_quo; { register short i; sign_quo = sign_dvd ^ sign_dvi; exp_quo = exp_dvd - expdvi; quotient = 0; for (i=0; i<31; i++) { quotient = (quotient << 1) & LO31BITS; /* shift up */ if (dividend >= divisor) /* can we subtract? */ { dividend -= divisor; /* then do it */ quotient |= BIT0; /* set lo-order bit on */ } dividend = (dividend << 1) & LO31BITS; /* shift up */ } } Hope this helps. ...!cca!ima!haddock!johna