Floating constant in Java.

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.

  1. 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
  2. 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

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: