I have run into a very strange problem in my code. I have a simple temperature converter where the user enters the temperature in Celsius and, after pressing \"Convert\", th
some languages allow you to put letters after number literals to signify what type it is.
if you simply wrote 12.3
, it might not know whether it is a float or a double(or it'd have to infer or cast it).
Your number parser must be picking up on these letters.
12.3d
is 12.3
as a double
12.3f
is 12.3
as a float
Java interprets numbers like 123f
as referring to a float
and 123d
as a double
, whereas plain 123
means an int
.
Read the documentation on the number format supported by parseDouble
. The f
and d
are instances of FloatTypeSuffix.