[英]What are the actual ranges of floating point and double data types in C#?
I'm learning C# and trying to get a logical visual representation of the actual range of data types in C#. 我正在学习C#,并试图获得C#中数据类型实际范围的逻辑可视表示。
I have moved through the integers and am now up to float and double data types. 我已经遍历整数,现在可以使用浮点数和双精度数据类型。
Here are the references to float and double data types sizes at msdn: 以下是msdn上对float和double数据类型大小的引用:
Float: http://msdn.microsoft.com/en-us/library/b1e65aza(v=vs.110).aspx 浮动: http : //msdn.microsoft.com/zh-CN/library/b1e65aza( v = vs.110).aspx
Double: http://msdn.microsoft.com/en-us/library/678hzkk9.aspx 双: http : //msdn.microsoft.com/en-us/library/678hzkk9.aspx
So, trying to keep with the convention of specifiying the actual range of numbers as in the numbered list above, what do these two ranges actually represent? 因此,尝试按照上面编号列表中指定数字的实际范围的惯例,这两个范围实际上代表什么?
The ranges are actually –infinity to +infinity. 范围实际上是–无限到+无限。
The largest finite float
is 340282346638528859811704183484516925440. This is 2 128 –2 128–24 . 最大的有限 float
是340282346638528859811704183484516925440。这是2 128 –2 128–24 。
The largest finite double
is 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368. This is 2 1024 –2 1024–53 . 最大的有限 double
是179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.这是2 1024 -2 一零二四年至1053年 。
The ranges are represented in "exponential format" for conciseness. 为简洁起见,范围以“指数格式”表示。 For example, +1.7e+308 means 17 followed by 307 zeros: 例如,+ 1.7e + 308表示17,后跟307个零:
1,700,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000 1,700,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000
So the exponential format is preferred for such large numbers. 因此,指数格式适用于如此大的数字。 And the same goes for extremely small numbers. 对于极小的数字也是如此。
Also, take a look at this reading by Jon Skeet. 另外,请看乔恩·斯基特(Jon Skeet)的读物 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.