存储和打印大于 2^64 的整数值 [英] Storing and printing integer values greater than 2^64

查看:18
本文介绍了存储和打印大于 2^64 的整数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个程序来查找梅森素数.使用 unsigned 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.

我应该能够使用像 **=><% 使用此数据类型.

I should be able to use operators like *, *=, > ,< and % with this data type.

推荐答案

你不能用 C 原生类型做你想做的事,但是有一些库可以处理任意大的数字,比如 GNU 多精度算术库.

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屋!

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