aherbert commented on pull request #780:
URL: https://github.com/apache/commons-lang/pull/780#issuecomment-884907417


   This issue is related to the BigDecimal equals method only returning true to 
binary equality. The same issue arises for Double or Float where there are two 
representations of zero:
   ```java
   Double d1 = Double.valueOf(-0.0);
   Double d2 = Double.valueOf(0.0);
   assert d1.equals(d2) == false;
   Float f1 = Float.valueOf(-0.0f);
   Float f2 = Float.valueOf(0.0f);
   assert f1.equals(f2) == false;
   ```
   I am not aware of other objects that can have a comparison that is 0 but not 
be equal. This applies to Numbers. I would suggest expanding the method to 
cover these cases of numbers:
   ```java
   public static boolean equalsOrCompareNumber(final Object object1, final 
Object object2);
   ```
   
   I have put an initial implementation on the Jira ticket. The details should 
be discussed there.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to