整数太大了 [英] Too big integers

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

问题描述

大家好


我想制作一个程序,需要使用太长的整数和

我认识的最大尺寸是无符号长,它存储数字

直到4294967295(在我的Turbo C 3.1中),但是这个尺寸太小了我想要做的事情。

。那么,如何在
C中存储大于此数字的数字?


谢谢,Guilherme

解决方案

hobbs< gu ************ @ uol.com.br>写道:

那么,我如何在C中存储大于这个数字的数字?




google for a bignum ''图书馆或开发自己的。


-

== Eric Gorr ========= http://www.ericgorr.net ========= ICQ:9293199 ===

因此,智能的考虑总是包括

的利益和伤害。 - 孙子

==侮辱,就像暴力一样,是无能的最后避难所... ===


开始跟进hobbs :

那么,如何在C中存储大于此数字的数字?




语言或标准库都不提供任何直接解决方案。

一些现代编译器提供额外的(非标准的)
64位整数类型,名称为long long。或__int64。


对于自定义大数字库,有两种方法:


1.二进制编码小数

2.一系列文字


可能你最好的选择是获得一个免费的图书馆。

我的推荐是

http://www.swox.com/gmp/

虽然我不能说它是否适用于您的特定平台。


-
$ b $bFürGoogle,Tux和GPL!


2003年12月26日00:11:28 GMT,Alexander Bartolich

< al *********** ******@gmx.at>在comp.lang.c中写道:

开始跟进hobbs:

那么,如何在C中存储大于这个的数字?


语言和标准库都没有提供任何直接的解决方案。
一些现代编译器提供了一个额外的(非标准的)64位整数类型,名称为长长的或者__int64。




[snip]


__int64确实是非标准的,但是long long自1999年10月以来一直是

ISO C标准的一部分,自5月以来一直是ANSI标准的一部分

2000.


Any不提供有符号和无符号长long类型的编译器
至少64位的
不符合当前的C标准。


-

Jack Klein

主页: http:// JK-Technology .Com

常见问题解答

comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html

comp。 lang.c ++ http://www.parashift.com/c++-faq- lite /

alt.comp.lang.learn.c-c ++ ftp://snurse-l.org/pub/acllc-c++/faq


Hi all

I want to make a program that will need to use too long integers and
the biggest size that I know is unsigned long, which stores numbers
until 4294967295 (in my Turbo C 3.1), but this size is too small for
what I want to do. So, how can I store numbers bigger than this one in
C?

Thanks, Guilherme

解决方案

hobbs <gu************@uol.com.br> wrote:

So, how can I store numbers bigger than this one in C?



google for a ''bignum'' library or develop your own.

--
== Eric Gorr ========= http://www.ericgorr.net ========= ICQ:9293199 ===
"Therefore the considerations of the intelligent always include both
benefit and harm." - Sun Tzu
== Insults, like violence, are the last refuge of the incompetent... ===


begin followup to hobbs:

So, how can I store numbers bigger than this one in C?



Neither language nor standard library offer any direct solution.
Some contemporary compilers offer an additional (non-standard)
64-bit integer type, going by the name of "long long" or __int64.

For custom big-number libraries there are two approaches:

1. Binary coded decimals
2. Array of words

Probably your best option is to grab a free library.
My recommendation is

http://www.swox.com/gmp/

though I can''t say whether it will work on your particular platform.

--
Für Google, Tux und GPL!


On 26 Dec 2003 00:11:28 GMT, Alexander Bartolich
<al*****************@gmx.at> wrote in comp.lang.c:

begin followup to hobbs:

So, how can I store numbers bigger than this one in C?



Neither language nor standard library offer any direct solution.
Some contemporary compilers offer an additional (non-standard)
64-bit integer type, going by the name of "long long" or __int64.



[snip]

__int64 is indeed non-standard, but "long long" has been part of the
ISO C standard since October 1999, and of the ANSI standard since May
2000.

Any compiler that does not supply signed and unsigned long long types
of at least 64 bits does not conform to the current C standard.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq


这篇关于整数太大了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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