KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Can every possible value of a float variable can be represented exactly in a double variable? In other words, for all possible values X will the following be successful: float f1 = X; double d = f1; float f2 = (float)d; if(f1 == f2) System.out.println("Success!"); else System.out.println("Failure!"); My suspicion is that there is no exception, or if there is it is only for an edge case (like +/- infinity or NaN). Edit : Original wording of question was confusing (stated two ways, one which would be answered "no" the other would be answered "yes" for the same answer). I've reworded it so that it matches the question title.
Tags (comma-separated)
Save Edits
Cancel