如何在C ++中存储1000000个数字整数 [英] how to store 1000000 digit integers in C++

查看:136
本文介绍了如何在C ++中存储1000000个数字整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的问题,我必须保存大的整数,如高达1000000数字,并做一些操作。我知道一个long int在c ++可以存储多达10个数字

in my problem i have to save big big integers like upto 1000000 digits and to do some operation. how can i do that.i know that a long int in c++ can store upto 10 digits

推荐答案

你可以使用 GMP ,GNU任意精度库。请注意,如果您的内存不足,它不是一个非常好的库。

You can use GMP, the GNU arbitrary precision library. Just be aware that it's not a very good library if you run out of memory.

这意味着它会退出下面你如果不能分配内存。我发现这是一个有趣...建筑决定一个通用的图书馆,但它是受欢迎的这种东西,所以,如果你愿意穿这种限制,这可能是一个不错的选择。

By that, I mean it will just exit out from underneath you if it cannot allocate memory. I find this an ... interesting ... architectural decision for a general purpose library but it's popular for this sort of stuff so, provided you're willing to wear that restriction, it's probably a good choice.

另一个好的是 MPIR ,GMP的一个分支,尽管名称为Multiple Precision Integers和Rationals,处理浮点相当好。我发现这些家伙比GMP开发人员在请求帮助或建议改进时更有帮助(但是,请注意,这是我的体验,您的里程可能会有所不同)。

Another good one is MPIR, a fork of GMP which, despite the name "Multiple Precision Integers and Rationals", handles floating point quite well. I've found these guys far more helpful than the GMP developers when requesting help or suggesting improvements (but, just be aware, that's my experience, your mileage may vary).

这篇关于如何在C ++中存储1000000个数字整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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