3 ms·
-2 and 1 are mod 3 essentially the same. I don't see here the problem except of course someone didn't expect this result and used it for indexing
by wolfi1 4y ago
-2 and 1 are mod 3 essentially the same. I don't see here the problem except of course someone didn't expect this result and used it for indexing
- qsort 4y agoSure, but then why if: -13 \equiv 5 \pmod 3 it is the case that: > -13 % 3 === 5 % 3 false I think it's better to use a convention where for all a, b, m, if a and b are congruent mod m, then a%m === b%m
- bajsejohannes 4y agoBut 13 is also equivalent to -2 and 1, mod 3. Why are you doing the modulo operation in the first place? From a mathematical standpoint, I've never seen a use for returning -2 here. I want something unique for the group, so I can ask e.g. `x mod 3 == y mod 3` and have it work regardless of whether x or/and y are negative.
- jhncls 4y agoYour safest bet would be `(x - y) mod 3 == 0`. Of course, that doesn't solve the case when you want to bin the values.