moonmath-manual icon indicating copy to clipboard operation
moonmath-manual copied to clipboard

Nitpick: Sage performs euclidean division with integer remainders as opposed to non-negative integers

Open dcbuild3r opened this issue 6 months ago • 0 comments

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)

dcbuild3r avatar Aug 20 '24 20:08 dcbuild3r