float f1 = 0.7f; float f2 = 8.125f; System.out.println(f1); System.out.printf("%.20f\n", f1); (exact upto 20 decimal places) System.out.println(f2); Wait… what? Why does 0.7f secretly become ...
If you’ve ever worked with prices or financial transactions in Java, you might have noticed something strange. Sometimes your calculations show extra decimal points like: In Java, float and double use ...