数字超过在C#中的基本类型 [英] Numbers that exceeds basic types in C#

查看:142
本文介绍了数字超过在C#中的基本类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我解决项目欧拉的问题。大部分由

解决的问题
    超过ULONG
  1. 在大的数字,

 例:ULONG数= 81237146123746237846293567465365862854736263874623654728568263582;
 

  1. 在非常敏感的十进制数显著的数字超过30
  

例如:十进制DEC =   0,3242342543573894756936576474978265726385428569234753964340653;

  1. 必须具有超过最大int值的指数值数组。
  

例:BOOL []项目=新   布尔[213192471235494658346583465340673475263842864836];

我发现了一个叫INTX库来解决这个大的数字。但我不知道我怎么能解决这个问题的基本.NET类型?

感谢您的答复!

解决方案

嗯,还有第三个项目,你真的不希望使用一个数组,因为它需要分配的大的好。

让我改了。

到时候你能负担得起,并且可以访问,那么多的内存,大数量的问题将得到解决!

要回答你的最后一个问题存在,也没有办法,只能用基本类型的解决这个问题,除非你是做什么的INTx的制造商一样,实现大数量的支持。

也许我建议你尝试不同的编程语言中的欧拉问题?我有更好的运气与Python,因为它有一个大的数字,开箱即用的支持和整合到一切。嗯,除了该数组,你真的不能做,在任何语言的这些日子。

I'm solving problems in Project Euler. Most of the problems solved by

  1. big numbers that exceeds ulong,

Ex : ulong number = 81237146123746237846293567465365862854736263874623654728568263582;

  1. very sensitive decimal numbers with significant digits over 30

Ex : decimal dec = 0,3242342543573894756936576474978265726385428569234753964340653;

  1. arrays that must have index values that exceeds biggest int value.

Ex : bool[] items = new bool[213192471235494658346583465340673475263842864836];

I found a library called IntX to solve this big numbers. But I wonder how can I solve this problems with basic .NET types ?

Thanks for the replies !

解决方案

Well, for the third item there you really don't want to use an array, since it needs to be allocated that big as well.

Let me rephrase that.

By the time you can afford, and get access to, that much memory, the big-number problem will be solved!

To answer your last question there, there is no way you can solve this using only basic types, unless you do what the makers of IntX did, implement big-number support.

Might I suggest you try a different programming language for the euler-problems? I've had better luck with Python, since it has support for big numbers out of the box and integrated into everything else. Well, except for that array, you really can't do that in any language these days.

这篇关于数字超过在C#中的基本类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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