1 2 Previous Next 21 Replies Latest reply: Mar 16, 2009 5:33 PM by 807588 RSS

    f suffix for floating point.

    807588
      Okay, I'm a proficient c++ programmer and have been learning Java for only a few weeks now.

      I have a question about the f suffix for floating point varibles such as float f = 3.14f;

      The f suffix casts this as float right? which is the same as float f = (float) 3.14; Correct?

      Why do we have to add the f suffix in the first place? Doesn't the compiler know that we want a float and not a double? (single-precision 32-bit instead of double precision 64 bit) I really do not understand the concept here or why they need the f suffix.

      Can someone explain?
        1 2 Previous Next