# Data Types continued. . .

**The Floating Number Type : float**

A variable declared to be of type “float” can be used for storing values containing fractional numbers. To display a floating-point value at the terminal, %f is used in printf as format specifier.

In scientific notation, a float is expressed as <mantissa>e<exponent>. The value 1.7e4 in this notation represents the value 1.7 × 10^4. The letter e, which separates the mantissa from the exponent, can be written in either lowercase or uppercase.

The format character %e should be specified in the printf format string, to display a value in scientific notation,.

We can also use %g to let “printf” decide whether to display the float value in normal floating-point notation or in scientific notation. If the value of the exponent is less than –4 or greater than 5, scientific notation format is used; otherwise, %f normal floating point format is used.

**The Extended Precision Type double**

Type “double” is used whenever the range of float type is not sufficient to hold the value.

Variables declared to be of type double can store almost twice as many significant digits as can a variable of type float.

Almost all computers represent double values using 64 bits.

All floating-point constants are taken as double values by the C compiler. To explicitly express a float constant, append either an f or F to the end of the number, like 12.5f

TYPE | SIZE | RANGE |
---|---|---|

float | 4 byte | 1.2E-38 to 3.4E+38 |

double | 8 byte | 2.3E-308 to 1.7E+308 |

long double | 10 byte | 3.4E-4932 to 1.1E+4932 |