How can I calculate it in C?
20X(77^2) mod 119
It's too big... even can't use pow/%/mod.....
thx!!
How can I calculate it in C?
20X(77^2) mod 119
It's too big... even can't use pow/%/mod.....
thx!!
How is that too big? A modulus can't get that big. Here is the code I used to check it:
I think your problem was the face that you didn't use a long int.Code:#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { long int number; number = (20 * pow(77, 2)); number = number % 119; printf("Answer: %d\n", number); system("PAUSE"); return 0; }
Good luck
Hi!
Did you know that you can even declare a long long int in C?
It works, but I have never used it.
klausi
When I close my eyes nobody can see me...
However... it doesn't work on me with long long int......Originally posted by klausi
Hi!
Did you know that you can even declare a long long int in C?
It works, but I have never used it.
klausi
anyway... thx!!
Accurate arithmetic on truly large numbers requires the support of a library.
Here's one example
http://swox.com/gmp/
Originally posted by biosx
How is that too big? A modulus can't get that big. Here is the code I used to check it:
I think your problem was the face that you didn't use a long int.Code:#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { long int number; number = (20 * pow(77, 2)); number = number % 119; printf("Answer: %d\n", number); system("PAUSE"); return 0; }
Good luck
I mean 20^77....
It shouldn't be number = (pow(20,77));??