Floating point constant in C language
Floating point constant
Definition: The numeric values having fractional part are called floating point constants. All negative Numbers should have prefix ‘ ’. A positive number may have a ‘+’ sign that is optional. OtherCharacter are not allowed . The floating point constant can be represented using two forms as:
1. Fractional form
2. Exponent notation(Scientific notation)
Fractional from: Now, let us see ‘‘how to represent floating point numbers using fractional form? Explain giving examples.’’ A floating point number represented using fractional form has an integer part followed by a decimal point and a fractional part. We can omit the digits before the decimal point or after the decimal point. For example, 0.5, 0.99, 6, 9,+.9 etc all are valid floating point numbers.
Exponent notation (Scientific notation): Now , the question is ‘‘How to represent floating point numbers in scientific notation? Give examples.’’ The floating point number represented using Scientific notation (also called exponential notation) has three parts namely:
(part1) (part2) (Part 3)
mantissa e or E exponent
 The mantissa can be an integer or a floating point number represented using fractional Notation.The letter e or should follow mantissa.
 The exponent should follow e or E. The exponent has to be an integer ‘‘with optional ‘+’
 Sign’’ or ‘ ’ sign.
The following table shows invalid floating point numbers. The reasons for invalidity are also shown:
Floating point/ Real Constant

Valid / invalid

Reasons for invalidity

22.0/7

Invalid

/ is not allowed.

120

Invalid

There is no decimal point.

6.5e 8

Invalid

White space is not allowed between e and 8.

1.2.3

Invalid

More than one decimal point is not allowed.

2.123,4

Invalid

Comma is not allowed

10.5e6.9

invalid

Fractional part 6.9 is not allowed in exponent part.

Floating point constant in C language
Reviewed by Bill Smithwick
on
February 19, 2015
Rating:
No comments