Floating point addition - giving strange result..!
When executing the following code: public class FPoint { public static void main(String[] args) { float f = 0.1f; for(int i = 0; i<9; i++) { f += 0.1f; } System.out.println(f); } } The following output is displayed: 1.0000001 But output should be 1.0000000 , right? Correct me if I'm wrong..!! 0.1 is not really "0.1" with IEEE 754 Standard. 0.1 is coded : 0 01111011 10011001100110011001101 (with float number) 0 is the sign (= positive) 01111011 the exponent (= 123 -> 123 - 127 = -4 (127 is the bias in IEEE 754)) 10011001100110011001101 the mantissa To convert the mantissa in decimal number we