You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For ints, division rounds towards 0 and the sign of a mod b is the sign of a. Meanwhile, for BigInts, division rounds towards negative infinity and the sign of a mod b is the sign of b.
I suggest we change the behavior of BigInts to match that of ints.
@def- since you implemented this, did you have a specific reason for implementing it this way?
The text was updated successfully, but these errors were encountered:
I think that generaly the motivation to implement it this way is that it doesn't break modular arithmetic. Meaning that if M divides (a-b) then a mod M == b mod M. If one does any sort of math with the integers, the other way (which is usually called remainder) gets in the way.
I think that it is really unfortunate that mod for ints means remainder rather than modulus, but that is to stay.
The ideal state would be there where two operators: rem implementing a remainder and mod implementing a modulo. For both ints and BigInts.
The behaviour of
div
andmod
is currently inconsistent with the respective operators forint
s. For example:prints the following:
For
int
s, division rounds towards 0 and the sign ofa mod b
is the sign ofa
. Meanwhile, forBigInt
s, division rounds towards negative infinity and the sign ofa mod b
is the sign ofb
.I suggest we change the behavior of
BigInt
s to match that ofint
s.@def- since you implemented this, did you have a specific reason for implementing it this way?
The text was updated successfully, but these errors were encountered: