Sindbad~EG File Manager
/* M. Beeson, for bignums.dll
/* multiply two unsigneds and get the two digits of the 64-bit answer,
without using assembly language. Corresponding code with Intel assembly
language is in lngmul32.c. This file is used to compile on non-Intel machines.
*/
#define BIGNUMS_DLL
#include "export.h"
#include "bignum.h" /* NN */
void longmult(unsigned x, unsigned y, unsigned *lo, unsigned *hi)
/* multiply two unsigneds getting an answer twice as long */
{ unsigned long long ans;
ans = ((unsigned long long) x )* ((unsigned long long) y );
*lo = (unsigned ) (ans & 0xffffffff);
*hi = (unsigned ) (ans >> 32);
}
/*_____________________________________________________________________*/
void longdiv(unsigned x, unsigned y, unsigned z, unsigned *q, unsigned *r)
/* divide a 64 bit number by a 32 bit number producing a 32-bit quotient
and remainder. Warning: overflow can occur if the true quotient is more
than 32 bits.
x = hi 32 bits of the dividend
y = lo 32 bits of the dividend
z = divisor
*q = quotient
*r = remainder
*/
{ unsigned long long xx = (((unsigned long long) x << NN) | y);
unsigned long long qq = xx/z;
*q = (unsigned) qq; /* overflow if qq is too large */
*r = (unsigned) (xx - qq*z); // corrected 10.30.03. This code is not used in Mathpert
}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists