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

Answer:

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

Size of Floats

Floating Point Primitive Data Types
TypeSizeRange
float32 bits-3.4E+38 to +3.4E+38
double64 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 extra memory used for double is not noticible 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 for the int value 221 the same as the pattern for the float value 221.0?