On Thu, Mar 12, 2009 at 4:16 AM, David Joyner <[email protected]> wrote:
>
> I have an ignorant question: what are the canonical reps of
> ZZZ/nZZZ in C? (-n/2,n/2]?
> Is the issue to decide between the interval [0,n-1] as reps of ZZ/nZZ (Python)
> vs (-n/2,n/2] (C)?

In C, ZZ/nZZ does not have canonical representatives.  For example,
the equivalent of [n%4 for n in [-7 .. 7]] would give:

-3, -2, -1, 0, -3, -2, -1, 0, 1, 2, 3, 0, 1, 2, 3

This is annoying to a mathematician.  The big reason in favor of this
is to align with division: both C and Python give a==(a/b)*b+a%b, but
Python uses floor division and C uses truncating division.

So why does C use truncating division?  I'm not sure what the choice
point was, but at this point two very important reasons would be:
because that's what the signed integer division instruction gives you
on basically all processors, and because that's what the C standard
has specified for years, so people have written code depending on that
behavior.  Given these facts, it's IMHO unlikely that C will ever
change.

Carl

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to