moonmath-manual
moonmath-manual copied to clipboard
Nitpick: Sage performs euclidean division with integer remainders as opposed to non-negative integers
When implementing the euclidean division algorithm as part of Exercise 3.2.6 I noticed that Sage doesn't define the remainder $r$ as a non-negative integer like in the book. It produces negative integers for certain inputs which caused some confusion when testing my implementation against Sage.
In this example the output will be $(3, -1)$ as opposed to $(4, 2)$ which satisfies the constraint of $r$ being a non-negative integer:
sage: ZZ(-10).quo_rem(ZZ(-3))
(3, -1)