Arithmetic error when adding two double values [duplicate]
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Floating point inaccuracy examples double arithmetic and equality in Java I caught this issue while trying to debug a sorting routine that checked if two values were equal. Getting the values was simply doing some addition on two double variables: 0.31 + 0.27. When the sort compared the sum of those two against the some of another objects, whose sum also equaled 0.58, it told me the comparison was not equal.