Fixing up the mod function to produce only positive results?
Subject: Fixing up the mod function to produce only positive results?
From: Alasdair McAndrew
Date: Tue, 15 Nov 2005 08:43:55 +1100
I've been doing some modular arithmetic with Maxima, and I don't like
the default behaviour than mod(m,n) returns a value between -(n-1)/2
and n/2 (roughly speaking). For example.
mod(18,7);
returns -3.
But I want my values to be positive, in the range 0..n-1. How can I
do this? Is there a local variable I can set, or do I have to edit a
lisp file (which I'd rather not do)?
cheers,
Alasdair