go to previous page   go to home page   go to next page hear noise

Answer:

double. As you might expect, it uses twice as many bits as a float.


Size of Floats

Floating Point Primitive Data Types
TypeSizeRangeAccuracy
float32 bits-3.4E+38 to +3.4E+38about 7 decimal digits
double64 bits-1.7E+308 to +1.7E+308about 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.


QUESTION 2:

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?