什么是双倍? (C#)
今天我想知道 .Net 中的 Double
。过去几天我将它与 Int32 一起使用,并开始想知道最大值是多少。
Double.MaxValue 的 MSDN 页面显示 1.7976931348623157E+308
。我很确定我读错了。
Double
占用多少字节(在内存中)?
实际最大数量是多少(解释一下E+308)?
Double.MaxValue 是否大于 UInt32?大于 UInt64
?
当我们讨论这个问题时,Float
和 Double
之间有什么区别?
Possible Duplicate:
What is the difference between Decimal, Float and Double in C#?
Today I'm wondering about Double
in .Net. I've used it with Int32
the past days and started wondering what the max value is.
The MSDN page for Double.MaxValue says 1.7976931348623157E+308
. I'm pretty sure I'm reading that wrong.
How many bytes does Double
take up (in memory)?
What is the actual maximum number (explain the the E+308)?
Is Double.MaxValue bigger than UInt32
? Bigger than UInt64
?
And while we are at it, what is the difference between Float
and Double
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基本上,
Double 是 64 位浮点值,而 float 是 32 位。
所以 double 能够存储两倍于 float 的值。
http://msdn.microsoft.com/en-我们/library/678hzkk9(v=vs.80).aspx
http://msdn.microsoft.com/en-us/library/b1e65aza(v=vs.71).aspx
只需阅读链接的顶行,您就会明白。
Basically,
Double is 64 bit floating point value and float is a 32 bit.
So double is able to store twice big value as of float.
http://msdn.microsoft.com/en-us/library/678hzkk9(v=vs.80).aspx
http://msdn.microsoft.com/en-us/library/b1e65aza(v=vs.71).aspx
Just read the top lines on the links, you'll get an idea.
关于
E+308
:尽管2^64
远小于1e+308
,但您必须考虑double
不是“精确”数字,它只有几个有效数字(精度),因此不需要存储所有~308 位数字。通过double
结构背后的逻辑,它可以包含高达e+308
的 64 位数字。About
E+308
: though2^64
is far less that1e+308
, you must consider thatdouble
is not "precise" number, it has only a few significant digits (precision), so it does not need to store all ~308 digits. With this logic behind thedouble
structure, it can contain numbers up toe+308
in 64 bits.