double
. As you might expect,
it uses twice as many bits as a float
.
Floating Point Primitive Data Types | ||
---|---|---|
Type | Size | Range |
float | 32 bits | -3.4E+38 to +3.4E+38 |
double | 64 bits | -1.7E+308 to 1.7E+308 |
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 to floating point data.
For output to the monitor or to a text file,
floating point data are converted to 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 two byte diffference
is not noticible 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 for the
int
value 221 the same as the pattern for the float
value 221.0?