Devaka Cooray wrote:Compare? If you need to check if the double values d1 and d2 are equivalent, that's what == operator is for.
There are a couple of things to note however:
1. We generally don't simply compare floating point types for equality using simply
d1 == d2. Because of the errors inherent in floating point calculations, we need to compare whether d1 and d2 differ by less than some epsilon.
2. The OP mentioned
Double with a capital
D. I don't know if that was a typo or deliberate. If we're dealing with Double objects (as opposed to double primitives), we
definitely don't want to use == .