编程语言如何处理大量算术运算 [英] How do programming languages handle huge number arithmetic

查看:172
本文介绍了编程语言如何处理大量算术运算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于使用64位处理器的计算机,它可以处理的最大数字是2 64 = 18,446,744,073,709,551,616。编程语言如Java或C,C ++如何处理高于此值的数字算法。任何注册都不能将其作为单件保存。这个问题是如何解决的?

For a computer working with a 64 bit processor, the largest number that it can handle would be 264 = 18,446,744,073,709,551,616. How does programming languages, say Java or be it C, C++ handle arithmetic of numbers higher than this value. Any register cannot hold it as a single piece. How was this issue tackled?

推荐答案

有许多专门的技术可以对大于寄存器大小的数字进行计算。其中一些内容在本维基百科文章中有关任意精确算术的概述

There are lots of specialized techniques for doing calculations on numbers larger than the register size. Some of them are outlined in this wikipedia article on arbitrary precision arithmetic

低级语言(如C和C ++)将大量计算留给您选择的库。其中值得注意的是 GNU Multi-Precision库。像Python这样的高级语言将其集成到语言的核心,因此正常数字和非常大的数字与程序员相同。

Low level languages, like C and C++, leave large number calculations to the library of your choice. One notable one is the GNU Multi-Precision library. High level languages like Python, and others, integrate this into the core of the language, so normal numbers and very large numbers are identical to the programmer.

这篇关于编程语言如何处理大量算术运算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆