Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-843

Providing new class BigDecimalUtils

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.1
    • Review Patch, Discussion
    • lang.*

    Description

      Creating Utils class BigDecimalUtils and offering a new implementation of method equals() in ObjectUtils.

      Quoting the javaDoc from BigDecimalUtils:

      Provides some extra functionality over the BigDecimal class type Comparing two different BigDecimals may be tricky, because yet the value is same, the format may differ and then the equals method implemented on BigDecimal does not return expected results.

      BigDecimal first = new BigDecimal("0.10");
      BigDecimal second = new BigDecimal("0.100");

      first.equals(second); will return false, because those two numbers are not using the same format, even though the values are both "0.1".

      Usage examples:
      Compare a number to 1: if(BigDecimalUtils.equals(someNumber, BigDecimal.ONE))
      compare two numbers whether they are the same value or both null: if(BigDecimalUtils.equals(someNumber, anotherNumber, NullsEquality.EQUALS))

      Attachments

        1. equalsUtils.patch
          20 kB
          Premysl Maly

        Activity

          People

            Unassigned Unassigned
            premma-profinit Premysl Maly
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: