Wednesday, January 20, 2016

Floating Point Constants/Literals

Floating point constants represents the floating point numbers, as the name suggests ie; numbers like 1.2, 3.6894 etc. In C programming language, we can represent a floating point constant in two ways,
  • Decimal point format or in
  • Exponent format.
In order to represent a floating point constant in decimal format, you need to include the decimal point (.) in the number. Floating point numbers can be expressed in exponent format like 1.23E-4 or 1.23e-4. It is another way to represent 1.23 x 10-4. The number after E can be signed, but should always be an integer. So, 3.56E1.2 is an invalid floating point constant. Some valid floating point constants in C are given below
3.968421
3968421E-6L
// Both of the above float literals represent the same value.

No comments: