Real literals are number having fractional parts.
These may be written in one of two forms:
1.Fractional form :
A real literal in Fractional Form consists of signed or unsigned digits including a decimal point between digits.
Rule----
Real constant in fractional form must have at least one digit with the decimal point, either before or after. It may also have either + or - sign represent it. A real constant with no sign is assumed to be positive.
Valid real literals in fraction form:
2.0, 17.5, -13.0, -0.00625, .3
Invalid literals in fraction form :
7 ------------(No decimal point)
+17/2 ----------( /-illegal symbol)
17, 250.26.2 ------- (Two decimal points)
17,250.262 ----------(comma not allowed)
2. Exponent form:
A real literal in Exponent form consists of two parts :mantissa and exponent .
For instance,
>>5.8 can be written as 0.58*10^1=0.58E01, where mantissa part is 0.58 (the part appearing before E).
>>exponent part is 1 (the part apearing after E).
>>E01 represent 10^1.
Rule------
Real constant in exponent form has two parts: mantissa and exponent . The mantissa must be either an integer or a proper real constant. The mantissa is followed by a letter E or e and the exponent.The exponent must be an integer.
Valid real literals in exponent form :
152E05, 1.52E07, 0.152E08, -0.172E-3, 172.E3, .25E-4 ,3.E3 (equivalent to 3.0E3)
Invalid literals in exponent form :
1.7E-----------( No digit specified for exponent)
0.17E2.3 ------------(Exponent cannot have fractional part)
17,225E02 ------------(No comma allowed)