积分常数太大(CS1021)-如何在数组中放入1000个非常大的整数(超过70个数字)? [英] Integral constant is too large (CS1021) - How to put 1000 extremely big (70+ digits) integers in an array?

查看:48
本文介绍了积分常数太大(CS1021)-如何在数组中放入1000个非常大的整数(超过70个数字)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SharpDevelop(C#)软件.

I'm using the software SharpDevelop (C#).

我已经创建了一个整数列表(数组),如下所示:

I've created a list of integers (array) like this:

int[] name = new int[number-of-elements]{elements-separated-by-commas}

{} 中,我想输入1000个整数,其中一些数字超过70位.

In the {} I would like to put 1000 integers, some with over 70 digits.

但是当我这样做时,出现以下错误:

But when I do that I get the following error:

积分常数太大(CS1021).

那我该如何解决这个问题?

So how do I solve this problem?

推荐答案

该错误并不表示您的数组中有太多整数.这意味着整数之一大于C#中 int 中可表示的最大值,即大于 2,147,483,647 .

The error does not mean that you have too many integers in your array. It means that one of the integers is larger than the maximum value representable in an int in C#, i.e. above 2,147,483,647.

如果需要使用70位数字表示,请使用 BigInteger :

If you need representation of 70-digit numbers, use BigInteger:

BigInteger[] numbers = new[] {
    BigInteger.Parse("1234567890123456789012345678")
,   BigInteger.Parse("2345678901234567890123456789")
,   ...
};

这篇关于积分常数太大(CS1021)-如何在数组中放入1000个非常大的整数(超过70个数字)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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