开发者

How does the cpu handle very large numbers?

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 kno开发者_运维技巧wn 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜