存储并打印整数值大于2 ^ 64 [英] Storing and printing integer values greater than 2^64
问题描述
我想写寻找梅森素数的程序。使用无符号long long类型,我能够确定9梅森素数,这是(2 ^ 61)-1的值。为较大的值,我需要,可以存储整数值大于2 ^ 64更大的数据类型。请帮忙。 (我应该能够使用类似的,运营商的=,>,<和%这种数据类型)
I am trying to write a program for finding mersenne prime numbers. Using the unsigned long long type I was able to determine the value of the 9th mersenne prime, which is (2^61)-1. For larger values I would need a data type that could store integer values greater than 2^64. Please help. (I should be able to use operators like ,=,>,< and % with this data type.)
推荐答案
您不能做你想做的用C当地人的类型,但也有一些让处理任意大的数字,喜欢的the GNU多个precision运算库。
You can not do what you want with C natives types, however there are libraries that let handle arbitrarily large numbers, like the GNU Multiple Precision Arithmetic Library.
这篇关于存储并打印整数值大于2 ^ 64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!