This week's book giveaway is in the Java 8 forum. We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line! See this thread for details.

when i compile the following code float f = 6.3f % 2.1f; The answer must be 0.0. but it's not. but when i try this code float f = 8.4f % 2.1f; the answer is 0.0.

Strange, I thaught that % (= modulus computation) is only defined for integers. But experimenting shows that it works in Java too for floats and then you can get rounding errors, because not all floats can be expressed exactly in (internal) binary format. What is done looks like: 6.3f-Math.round(6.3f/2.1f)*2.1f mimicing 'real modulus' computation. So I would not use 'modulus' with floats.