[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: arithmetic issues

This page is part of the web mail archives of SRFI 77 from before July 7th, 2015. The new archives for SRFI 77 contain all messages, not just those from before July 7th, 2015.

 | From: Taylor Campbell <campbell@xxxxxxxxxx>
 | Date: Fri, 21 Oct 2005 20:24:55 +0000 (UTC)
 | ...  A convenient syntax might be added on top of this, such as:
 |   (with-modular-arithmetic 32 (+ arithmetic-shift)
 |     (+ 1 (bitwise-not (arithmetic-shift -1 32))))
 |     => 0
 | (The first operand specifies the modulus; the second, a list of
 | names to be bound to appropriate arithmetic operations.  I'm not
 | entirely sure whether this is the right kind of syntax, but it is
 | one possibility.)

Be careful.  When dealing with polynomials, the coefficient arithmetic
must be independent of the exponent arithmetic.  At least one computer
algebra system truncated their polynomials when the coefficients were
computed in modular arithmetic!