Hi,

At 05:34 PM 4/2/99 EST, Foghorn Leghorn wrote:
>I wrote the following:
>
>unsigned long mulmod(unsigned long a, unsigned long b, unsigned long n)
>{
>       long double tmp, q;
>       tmp = a * (long double)b;
>       q = floorl(a * (long double)b / n);
>       return tmp - q * n;
>}
>
>In my testing, this appears to give the correct result for any 32-bit 
>values of a, b, and n, thanks to the 64-bit precision of Intel's 80-bit 
>floating point type. Is there anything wrong with this approach?

A compiler is allowed to store values in 53-bit precision memory locations
at any point during the floating point computation.  Thus, whether or
not your code works on any 32-bit values is completely compiler-dependent.

Best regards,
George 

________________________________________________________________
Unsubscribe & list info -- http://www.scruz.net/~luke/signup.htm

Reply via email to