modulus - Why is Matlab Mod different from Wolfram Alpha -


688^79 mod 3337 = 1570.

when tried @ wolfram alpha got: enter image description here

but when entered same thing in matlab, 364 answer. got doing wrong.

enter image description here

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 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

utf 8 - split utf-8 string into bytes in python -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -