John Stalker wrote:
|
| So, what *is* -5 MOD 3?
|
-2
I hope not. If you are really serious about using modular arithmetic
then you probably want to use something like PARI GP where -5 mod 3
is -5 mod 3, belonging to the data type of integers mod 3. -2 mod 3
and 1 mod 3 are alternate representations of the same value. If you
aren't serious about modular arithmetic and want the result to be an
integer then I think you are shooting yourself in the foot if you
implement it as anything other than -5 mod 3 == 1. I want to be able
to test whether n is odd with `if ( n % 2 == 1 ) ...' Of course, I'm
a mathematician rather than a CS person, but I think the other
convention has nothing to recommend it.
Agreed on this. At least most (all I know) cryptography protocols
require -5 mod 3 to be 1 for their implementations. At least lots of
algorithms require ... == -5 mod 3 == -2 mod 3 == 1 mod 3 == 4 mod 3 == ....
--
Victor Nazarov
http://vir.comtv.ru/