C#中浮点和双精度数据类型的实际范围是什么? [英] What are the actual ranges of floating point and double data types in C#?

查看:521
本文介绍了C#中浮点和双精度数据类型的实际范围是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习C#,试图获得C#中实际数据类型范围的逻辑可视化表示。



我已经遍历整数,现在直到浮动和双数据类型。


  1. 8位(1字节),sbyte,-128至127.
    <8> 1字节),字节,0到255.
  2. 16位(2字节),short,-32,768到32,767。
    16位(2字节),ushort,0到65535.
    32位(4字节),int,-2,147,483,648到2,147,483,647。
    <32> 32位(4字节),uint,0到4,294,967,295。
    64位(8字节)长,-9,223,372,036,854,775,808至9,223,372,036,854,775,807
    64位(8字节),ulong,0至18,446,744,073,709,551,615。
  3. li>

下面是对msdn的float和double数据类型大小的引用:



浮动:




所以,试图按照上面编号列表中规定数字的实际范围的惯例,这两个范围起什么作用同盟代表?

解决方案

为简明起见,范围以指数格式表示。例如,+ 1.7e + 308是指17个其次是307个零点:$ b​​
$ b 17000000000000000000000000000000000000000000











那么指数格式这样的大数量是优选的。对于极小的数字也是如此。


另外,请看这篇阅读通过Jon Skeet。

I'm learning C# and trying to get a logical visual representation of the actual range of data types in C#.

I have moved through the integers and am now up to float and double data types.

  1. 8 bits (1 byte), sbyte, -128 to 127.
  2. 8 bits (1 byte), byte, 0 to 255.
  3. 16 bits (2 bytes), short, -32,768 to 32,767.
  4. 16 bits (2 bytes), ushort, 0 to 65535.
  5. 32 bits (4 bytes), int, -2,147,483,648 to 2,147,483,647.
  6. 32 bits (4 bytes), uint, 0 to 4,294,967,295.
  7. 64 bits (8 bytes), long, -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
  8. 64 bits (8 bytes), ulong, 0 to 18,446,744,073,709,551,615.

Here are the references to float and double data types sizes at msdn:

Float: http://msdn.microsoft.com/en-us/library/b1e65aza(v=vs.110).aspx

Double: 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 represented in "exponential format" for conciseness. For example, +1.7e+308 means 17 followed by 307 zeros:

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

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.

这篇关于C#中浮点和双精度数据类型的实际范围是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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