I already know how to compare floats and this is not the question.
When I compare float I cannot just do that:
if(flot1 == flot2) {
// do something
}
Indeed I was always taught to do something like this:
if(Math.abs(float1 - float2) < epsilon) {
// do something
}
But the question is when I use float wrappers... for example there is something as simple as the method equal():
if(floatWrapper1.equals(floatWrapper2)) {
// do something
}
But reading the documentation that this is equivalent to:
if(floatWrapper1.floatValue() == floatWrapper2.floatValue()) {
// do something
}
That is the same like the example (2) that is wrong for the purpose of comparison.
Looking in internet I then found some examples like this:
if(Float.compare(flotWrapper1, floatWrapper2) == 0) {
// do something
}
But, I was wonder if this is right neither. How should I then compare two float wrappers?