4 Replies Latest reply on Sep 30, 2009 2:58 PM by 3004

    Floating point literals

      Hi, This is a something that when I first started learning java I skimmed over, and now I have a question that is bugging me about floating point literals.

      If all floating point literals in java are automatically a double type then is the reference to a float ignored when the class is compiled?

      I know its probably a stupid question, but the thing that is bugging me is that I always thought the reference was used to allocate memory, if the reference is a float which is 32 bits, but the compiler assumes the type is double which is 64 bits because all floating point literals that are not suffixed are double then what happens with the float declaration? Is it ignored and double used instead?

      I have been googling for an answer and didnt find one that explained what happens, only answers that indicate that double is the default and that I could use a suffix of 'f' if I want the literal to be a float.

      Edited by: PaulOckleford on Sep 30, 2009 12:21 AM