how Decimal data type evaluatesto such a long range while it's precision is 29 digits only
what is the a开发者_Go百科ctual mechanism by which Decimal does calculations upto such a big range(1.7E+308) while it's precision is only 29 digits and it also takes only 8 Bytes.
It doesn't - decimal
only works up to 29 digits and the maximum value is 79,228,162,514,264,337,593,543,950,335.
double
, however, has fewer significant digits but a much bigger range. It does this by becoming much less precise for larger numbers. The exponent part can be much larger in double
than in decimal
.
I have articles on binary and decimal floating point arithmetic in .NET which explain the storage format in more detail.
Oh, and decimal
takes 16 bytes, not 8.
精彩评论