如何处理任意大的整数 [英] How to handle arbitrarily large integers
本文介绍了如何处理任意大的整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编程语言,今天我得到了一个点,我可以编译阶乘函数(递归),但是由于一个整数的最大大小,我可以得到的最大的是factorial(12)。什么是一些用于处理任意最大大小的整数的技术。
I'm working on a programming language, and today I got the point where I could compile the factorial function(recursive), however due to the maximum size of an integer the largest I can get is factorial(12). What are some techniques for handling integers of an arbitrary maximum size. The language currently works by translating code to C++.
推荐答案
如果你需要大于32位,你可以考虑使用64位整数(长整型),或使用或写入任意精度的数学库,例如 GNU MP 。
If you need larger than 32-bits you could consider using 64-bit integers (long long), or use or write an arbitrary precision math library, e.g. GNU MP.
这篇关于如何处理任意大的整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文