What is Double? (C#)
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
?
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.
About E+308
: though 2^64
is far less that 1e+308
, you must consider that double
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 the double
structure, it can contain numbers up to e+308
in 64 bits.
上一篇: C#问题与双号码
下一篇: 什么是Double? (C#)