double
. As you might expect,
it uses twice as many bits as a float
.
Floating Point Primitive Data Types | |||
---|---|---|---|
Type | Size | Range | Accuracy |
float | 32 bits | -3.4E+38 to +3.4E+38 | about 7 decimal digits |
double | 64 bits | -1.7E+308 to +1.7E+308 | about 16 decimal digits |
In main storage and in disk storage, a float
is
represented with a 32-bit pattern and a double
is
represented with a 64-bit pattern.
For input from the keyboard,
character data must be converted into floating point data.
For output to the monitor or to a text file,
floating point data must be converted into characters.
You almost never need to worry about the range of numbers that
can be represented in a floating point variable.
Ordinarily you use a double
when you
need a floating point type. The range and accuracy are both
much better than with a float
and the extra memory used for double
is not noticeable unless you are building a very large data structure.
The data type int
and the data type float
both use 32 bits.
Is the pattern of the 32 bits for the
int
value 221 the same as the pattern for the float
value 221.0?