The integer data types are very useful when it comes to the process of software development. However, there arises the necessity of using floating-point numbers when financially and mathematically oriented programs are to be developed. Hence, the data types like float, double and long double come handy in such conditions. The floating-point allows the programmer to represent a large range of number, including decimal fractions. Floating-point number representation has similarities with scientific notation, which is a system used by scientists to express very large and small numbers.
The numbers are represented as decimal numbers times the power of 10 in scientific notation. The table given below shows the representation of numbers in ordinary, scientific and exponential notations:
|Number||Scientific Notation||Exponential Notation|
|1,000,000,000||1.0 × 109||1.0e9|
|123,000||1.23 × 105||1.23e5|
|322.56||3.2256 × 102||3.2256e2|
|0.000056||5.6 × 10-5||5.6e-5|
The first column displays the usual notation of number, the second displays the scientific notation and the third displays the exponential notation, or simply e-notation, which is how scientific notations are usually written for and by computers, with e followed by the power of 10.
Points to Remember
- In C, the float data type can represent at least six significant figures and allow a range of at least 10-37 to 10+37.
- C provides double data type for double precision floating-point values. The double type has the same minimum range requirements as float, but it extends the minimum number of significant figures that can be represented to 10. Typical double representations use 64 bits instead of 32 bits. Some systems use all 32 additional bits for the non-exponential part. This increases the number of significant figures and reduces errors caused due to round-off. Other systems use some of the bits to accommodate a larger exponent which increases the range of numbers that can be accommodated. Either approach leads to at least 13 significant figures, more than meeting the minimum standard.
- C allows long double data type. It provides more precision than double does. However, C guarantees only that long double is at least as precise as double.