This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes floats and doubles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "floats and doubles" Watch "floats and doubles" New topic

floats and doubles

ed suttner

Joined: Mar 04, 2003
Posts: 13
On page 12 it states that 2546789.343 is a double. Also on question 9, p 48, the answer states that B 3.14 is a float as well. How can you tell it is a double and not a float? I guess my question is how can you tell if a number is a float or a double by just looking at it. Thanks. ed
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
If the number has a decimal point (3.14) or uses scientific notation (5e6) then it is a floating point number.
If it has an f or F at the end (3.14f) then it is a float. otherwise it is a double. 3.14 is a double, not a float.

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
hi ed suttner
How can you tell it is a double and not a float?
If you have time, I prefer to use the method that using the compiler to test the programme. Because we may be confused by the content of book which may be wrong.

Francis Siu
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: floats and doubles
Similar Threads
Floating point
How are the float and boolean variables stored?
doubt: equals&==
How NOT to convert dollar to cents