什么是数字,可以被存储在.NET数字数据类型的最大数量 [英] What is the maximum number of digits that can be stored in a .NET numeric data type

查看:154
本文介绍了什么是数字,可以被存储在.NET数字数据类型的最大数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这仅仅是出于好奇。我们知道,对密码学应用的两个大质数(超过100位)相乘,以形成公开密钥的一部分。那么,哪Microsoft.NET号码类型可存储上百位的最大素数?换句话说这数字数据类型可容纳.NET最大的整数?据我所知,System.Double,它使用8个字节,可存储的最大值(1.79769313486232×10 ^ 308) - 这大概可容纳309位。然而,System.Decimal占用16个字节,可以存储79228162514264337593543950335一个最大值这是只有29小数位数(小超过两位数?)

This is just out of curiosity. We know that for cryptology applications two large prime numbers (of more than 100 digits) are multiplied to form a part of the public key. So which Microsoft.NET number type can store the largest prime numbers, of hundreds of digits ? In other words which numeric data type can accommodate the largest whole number in .NET ? I understand that System.Double which uses 8 bytes, can store a max value of (1.79769313486232 × 10^308) - this probably accommodates 309 digits. However, System.Decimal uses 16 bytes and can store a max of 79228162514264337593543950335 which is only 29 decimal digits (lesser digits than Double ?)

谢谢, 泽。

推荐答案

如果您使用的是.NET 4,看一看的 System.Numerics.BigInteger 它可以存储任意大的整数。

If you're using .NET 4, have a look at System.Numerics.BigInteger which can store arbitrarily large integers.

做的没有的店309个数字 - 它具有广泛的范围的,但它只有15-16的precision数字。换句话说,如果你转换的​​大值(例如那些仅低于 long.MaxValue )以和后面你就会失去信息。请参阅我的文章在二进制和的十进制浮点类型以获取更多信息。

double does not store 309 digits - it has a wide range, but it only has 15-16 digits of precision. In other words, if you convert large long values (e.g. those just below long.MaxValue) to double and back you'll lose information. See my articles on binary and decimal floating point types for more information.

这篇关于什么是数字,可以被存储在.NET数字数据类型的最大数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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