modulus - Why is Matlab Mod different from Wolfram Alpha -
688^79 mod 3337 = 1570.
when tried @ wolfram alpha got:
but when entered same thing in matlab, 364 answer. got doing wrong.
any light on appreciated.
the reason matlab uses double
floating-point arithmetic default. number large 688^79 can't represented accurately double
. (the largest integer can accurately represented double
of order of 2^53).
to obtain right result can use symbolic variables, ensures don't lose accuracy:
>> x = sym('688^79'); >> y = sym('3337'); >> mod(x, y) ans = 1570