Floating point constant in C language

February 19, 2015 , 0 Comments

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. Other
Character  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
/ is not allowed.
There is no decimal point.
6.5e 8
White space is not allowed between e and 8.
More than one decimal point is not allowed.
Comma is not allowed
Fractional part 6.9 is not allowed in exponent part.

Bill Smithwick

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google