is there another way to calculate a*a mod m mathematically? m is larger than a so (a%m)*(a%m) %m doesn't do anything, but a*a is large enough to overflow.
Addressing a*a mod m overflow problem where m is large
0
$\begingroup$
modular-arithmetic
-
0Which sizes are we talking about here? What kind of arithmetic do you have access to? – 2012-04-11
-
0Anything doable in C++ – 2012-04-11
-
0I assume that you're already using `long` rather than `int` in your code? If so, then you should use the GMP bignum types for arbitrary precision arithmetic: http://gmplib.org/ – 2012-04-11
-
0I'm using int64's -- unfortunately I had a very difficult time getting GMP to work – 2012-04-11