BigDecimalDiscriminator

A BigDecimalDiscriminator discriminates BigDecimals. It discriminates its input by discriminating the BigDecimal's scale first, as determined by the scale() method, then on each element of the byte array of values that make up the BigDecimal, as determined by calling unscaledValue().toByteArray(). Before discrimination, it calls stripTrailingZeros() on the BigDecimal, so that BigDecimals that only differ on scale, e.g. 6.00 and 6, will compare the same.

Example

Given the input...

  • {6.00, 6, 123456789012345678901234567890, 0, -56, 6, 56, -56, 1.000}

... a BigDecimalDiscriminator returns the following equivalence classes:

  • {123456789012345678901234567890}
  • {0}
  • {56}
  • {1.000}
  • {6.00, 6, 6}
  • {-56, -56}