NAME: RAHUL SAMANTA DEPARTMENT: ELECTRICAL ENGINEERING SEMESTER: 2 nd YEAR: 1 st SUBJECT: COMPUTER SCIENCE (CS-201) TOPIC: FLOATING POINT CONSTANT
FLOATING POINT CONSTANT IN C LANGUAGE It is a part of numeric constant. It is also known as real constant.
CONSTANTS INTEGER FLOATING POINT CHARACTER STRING
DESCRIPTION OF FLOATINT POINT CONSTANT A " floating - point constant " is a decimal number that represents a signed real number. The representation of a signed real number includes an integer portion, a fractional portion, and an exponent. We use floating - point constants to represent floating - point values that cannot be changed.
A floating-point constant consists of: Decimal integer Decimal point Decimal fraction e or E and a signed integer exponent (optional) Type suffix: f or F or l or L (optional) NOTE Either decimal integer or decimal fraction (but not both) can be omitted. Either decimal point or letter e (or E ) with a signed integer exponent (but not both) can be omitted. These rules allow conventional and scientific (exponent) notations. Negative floating constants are taken as positive constants with an unary operator minus (-) prefixed.
TYPES There is total three types float no suffix defines double f F defines long double l L defines
SYNTAX floating-point-constant : fractional-constant exponent-part floating-suffix digit-sequence exponent-part floating-suffix fractional-constant : digit-sequence . digit-sequence digit-sequence . exponent-part : e sign digit-sequence E sign digit-sequence sign : one of + - digit-sequence : digit digit-sequence digit floating-suffix : one of f l F L
EXANPLE PROGRAM 1 2 3 4 5 6 7 8 9 10 #include<stdio.h> #include<conio.h> int main () { const float a = 2E - 4 ; clrscr (); printf ( “ Value of a =% e” , a ); getch (); return ; } Output Value of a = 2.000000e-04