Why is 65.12 - 2 not equal to 63.12 in java? [duplicate]
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Floating point arithmetic not producing exact results in Java I was recently working on a project when I came across a strange bug. When 2 was subtracted from 65.12 the value was greater (not equal to) 63.12. Here's the simplified code: System.out.println(65.12-2); And the output in the console: 63.120000000000005 I'm not sure why this is the case and if anyone knows a simple fix/workaround that would be great!