Q15. What is a floating constant in Java? How many ways can a floating constant be represented into?
Ans. Floating literal( floating constant) are also called real literals.
Real literals are numbers having fractional parts. These may be written in one of the two forms called fractional form or the exponent form.
- A real literal in fractional form consists of signed or unsigned digits including a decimal point between digits. The following are valid real literal in fractional form: 2.0, 7.5, -3.0, -0.00656
- A real literal in exponent form consists of two parts: mantissa and exponent. For instance 5.8 can be written as 0.58 x 101
= 0.58E01 where mantissa part is 0.58( the part appearing before E) and exponent part is 1 ( the part appearing after E). The following are valid real literal in exponent form: 152E05, 1.52E07, 0.152E08, -0.172E-3, 152E+8