Question

Given that the registers on a CPU are of fixed length, how does the CPU's handle large numbers?

For example, on a 32 bit system, using a two complements system, a integer can hold values between 0 and 4,294,967,295. Now the largest known prime number is 12,978,189 digits in length.

In checking that the largest prime is actually prime, how would the CPU store the number in order to perform the operations?

Was it helpful?

Solution

A register just dictates the immediate values a CPU can work with, not the total amount of memory it can access. Think back to how you add large numbers on paper, working one digit at a time, carrying a 1 or a 2 and moving on. A program to work with large numbers basically uses a similar approach, but probably with optimizations. The only limit at that point, is how much storage you have.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top