| Author |
Float and Double Data Type
|
Jessica Lang
Ranch Hand
Joined: Jul 23, 2002
Posts: 61
|
|
Hello, float scores[] = (76.0, 84.5, 92.5, 88.0, 96); Compilation error: possible loss of precision found: double required: float Why the float type is insufficient for the storage of one decimal point value? The above statements compiled with no error if double type is used. Thanks....
|
 |
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
|
|
Don't forget the constants initializing the array are double precision numbers. If you want to initialize the float array (that is single precision), you must write the constants as 76.0F, 84.5F, 92.5F, 88.0F, 96.0F. [ May 15, 2003: Message edited by: Barry Gaunt ]
|
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
|
 |
Jessica Lang
Ranch Hand
Joined: Jul 23, 2002
Posts: 61
|
|
Oh yeah, I just remembered that! I think I read it somewhere....Thanks again.....
|
 |
 |
|
|
subject: Float and Double Data Type
|
|
|