It explains what exponent and mantissa is. Because double and decimal have a fixed size in computer memory in C# language, designers had to decide how many bits should be spent on matissa and how many for exponent. And as for C# language it is illustrated below:

A double represents a number of the form +/- (1 + F / 252 ) x 2^{E-1023}, where F is a 52 bit unsigned integer and E is an 11 bit unsigned integer; that makes 63 bits and the remaining bit is the sign, zero for positive, one for negative. A decimal represents a number in the form +/- V / 10^{X}where V is a 96 bit unsigned integer and X is an integer between 0 and 28.

It all means that decimal is much safer in doing a correct computations than double.

## No comments:

Post a Comment