Answer the question
In order to leave comments, you need to log in
How to perform mathematical operations with large numbers?
Created an algorithm for determining the number of prime.
I wrote a program in C++, which checks the largest prime number 18446744073709551557 from the range 1 ... 2^64 - 1 in 7-8 seconds.
Now I would like to work with numbers of arbitrary length, but I do not know how.
In general, you need to perform three operations with large numbers: calculating the square root of a number (sqrt), rounding the number to the nearest integer (ceil) and modulo (remainder of division, %).
Tell me how you can organize these three operations on superlarge numbers in C++.
Answer the question
In order to leave comments, you need to log in
There is a ready and fast enough implementation in openSSL - BN. You can use it, you can look at their sorts (but the devil will break his leg there). There is also MIRACL (also with sorts), but they have performance problems and the documentation is not very good in places. You can look at GMP, but have not personally used it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question