I originally tried to email Dave Griffith directly but the email on the Community Wikki seems to no longer be valid. So instead I'll post here since I know he reads the forums:
I was recently reading up on decimal comparisons and some of the problems that can result from such (http://www-106.ibm.com/developerworks/java/library/j-jtp0114/) The InspectionGadgets plugin has an existing inspection that warns if code is using equality (==) comparison of floats/doubles, but the inspection does not offer any suggestions on how to fix the problem. It would be nice if the check could offer an intention to convert a float/double comparison into code that looks something like this:
new Float(a).compareTo(new Float(b)) == 0
new Double(a).compareTo(new Double(b)) == 0
Or in java 1.4+ this can be converted to the much simpler:
A slightly similar problem can also exists for the BigDecimal class. The equals() method will return true if both BigDecimals have the same number of decimal places but returns false if they don't even if the numbers are actually the same (for instance 0.01 would not be considered equal to 0.010). The compareTo() method does correctly compare these values so an intention that suggests changing 'BigDecimal.equals(BigDecimal)' into 'BigDecimal.compareTo(BigDecimal)==0' would be useful
In addition to the equality comparison for float and doubles, it would be nice if there was an inspection that warned of any float or double comparisons.
'a > b' could be changed to ' new Float(a).compareTo(new Float(b)) > 0'
'a < b' could be changed to ' new Float(a).compareTo(new Float(b)) < 0'