I would like to understand the meaning of a double-precision variable.
I would like to understand the meaning of a double-precision variable.
Typically called double
is the variable that stores a number of floating point with space to indicate larger numbers, either in the whole part or in the decimal part. He is the "brother" of type float
which is the kind of simple precision. Usually the float
occupies 4 bytes and the double
occupies 8 bytes. Some implementations occupy 10 bytes and up to 16 bytes, although in this case it may be called quadrupling precision.
Actually variable is just a name for a storage location. Values have types. In static typing languages variables accept values of only one type as a code declaration.
Floating-point types are often implemented by binary representation so that calculations are done quickly by processors. If the representation were even decimal the calculation would not be natural to the processor and would take much longer. There is a downside to this choice. There is no accuracy, so not all numbers can be represented this way. You can always represent a very close number, which is almost the same, but not exactly the same. It is not a problem for scientific calculations, but to represent money it is no good. Money needs the exact value. Never use float
and double
for money or other values that need accuracy.
Then understand that accuracy and precision are different things. Accuracy has more to do with the ability to express larger numbers, but more houses to the right or left. Accuracy is the degree of variation of the results of a measurement. Accuracy , which refers to compliance with the actual value.
Floating-point numbers are stored with a significant value multiplied by a fixed base raised to an exponent , in addition to signal.
Simple Precision:
DoublePrecision:
The more bits available, the more the number can be accurate.