Floating Point Data Types

The floating point data types are used to represent real numbers (i.e. numbers representable via a decimal expansion). Up to three different sizes of floating point numbers can be defined, as shown below.

float        //  32 bit
double       //  64 bit (internal 80 maybe)
long double  //  64 or 80 bit

It is guaranteed that:

precision of float <= precision of double <= precision of long double.

Floating Point Constants

A floating point constant consists of:

Either the integer or decimal part of the constant may be missing, but not both. Either the decimal point or the exponent may be missing, but not both.


double a,b,c;       // three uninitialized numbers
double d = 100.001; // a number holding 100.001
double e = 1e2;     // a number holding 100 = 1 x 10*10
double f = 1e-2;    // a number holding .01  - negative exponent
double g = .01;     // a number holding .01  - integer part missing
double h = 1.1e2;   // a number holding 110 - all parts present