用于任意数字精度的 .NET Framework 库
我正在重新提出这个问题,并使其更加具体:是否有一个 .NET 框架库支持具有任意精度数字的数字?
I'm reviving this question, and making it more specific: Is there a .NET framework library that supports numbers with arbitrary digits of precision?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
您可以使用十进制类型,它提供 28-29 个有效数字
You can use decimal type which gives you 28-29 significant digits
这是一篇关于如何表示无限数字的好文章。
http:// dobbscodetalk.com/index.php?option=com_myblog&show=Basic-Arithmetic-with-Infinite-Integers.html&Itemid=29
祝你好运
Here is a good article on how to represent infinite digits.
http://dobbscodetalk.com/index.php?option=com_myblog&show=Basic-Arithmetic-with-Infinite-Integers.html&Itemid=29
good luck
您可以尝试旧的尾数方法。 基本上,您可以使用 64 位整数来存储数字,然后使用 64 位整数来存储指数(可能为负数)。 您可以构建自己的对象类型并重载算术运算符,因此它将被视为单个数字。 这需要一些工作,但我认为这将是您的最佳选择。
You could try the old method of mantissa. Basically you could have an 64 bit integer for storing the number and then a 64 bit integer for storing the exponent (which could be negative). You could build your own object type and overload the arithmetic operators, so it will be treated as a single number. It will require some work, but I think it will be your best option.
GnuMpDotNet:http://www.emilstefanov.net/Projects/GnuMpDotNet/
如果您需要纯.NET考虑研究一下:http://www.codeplex.com/IntX/
GnuMpDotNet: http://www.emilstefanov.net/Projects/GnuMpDotNet/
If you need pure .NET consider looking into this: http://www.codeplex.com/IntX/
也许令人惊讶的是,Bailey-Borwein-Plouffe 公式 给出了一个增量过程,用于计算 pi 的下一个二进制或十六进制数字,而不需要存储所有前面的数字。
Perhaps surprisingly, the Bailey-Borwein-Plouffe formula gives an incremental procedure for computing the next binary or hexadecimal digit of pi without needing to store all the previous digits.
如果您想要一个非常快的库,请尝试:
http://www.emilstefanov.net/Projects/GnuMpDotNet /
If you want a really fast library then try:
http://www.emilstefanov.net/Projects/GnuMpDotNet/
您能等待 .NET 4.0 吗? 他们是将 BigInteger 直接引入框架。
另一方面,如果您等不及,那么 J# 运行时包含内置的-支持java.math.BigInteger 和BigDecimal。 就像 .NET Framework 的其余部分一样,它是可重新分发的。
Can you wait for .NET 4.0? They're bringing BigInteger directly into the Framework.
On the other hand, if you can't wait, then the J# runtime includes built-in support for java.math.BigInteger and BigDecimal. This is redistributable just like the rest of the .NET Framework.
这里有几个选项。
一个不错的选择是 W3b.Sine,它是原生 C#/.NET,并且支持任意精度浮点值。
如果您只处理整数值,IntX 提供对任意精度整数值的支持。 一个可能更成熟的选项是 C# BigInt,但同样,这不支持浮点运算。
There are a few options here.
A good option is W3b.Sine, which is native C#/.NET, and supports arbitrary precision floating point values.
If you are only dealing with integer values, IntX provides support for arbitrary precision integer values. A potentially more mature option would be C# BigInt, but again, this will not support floating point operations.