This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I was working on this question and this was the answer. When I ran it on my machine, I came up with "True". The following code will print 'false'. float f = 1.0F/3.0F; System.out.println( (f * 3.0F) == 1.0F );
I think the point of it is it will not always print true on every machine. Since float values lose precision, when you do 1.0F/3.0F you may get .333333333334 and then when you mutiply that by 3.0f you may get 1.00000000001 which won't equal 1.0f. Bill
Hi guys, I guess there is no error, As the question is,"will the code below print, false" So the answer has to be false....as you all know that, the code will print "true". NO ERROR....it's the way you read the question Mukti