Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-755

On the contract of FieldElement<T>.divide(T)

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0, 3.1
    • Fix Version/s: 3.1
    • Labels:

      Description

      As discussed on the mailing list:

      The contract of FieldElement<T>.divide(T) states that an ArithmeticException should be thrown if the parameter is zero. However, for this boundary case

      • BigFraction throws ZeroException
      • BigReal throws ArithmeticException
      • Complex uses NaNs instead of exceptions
      • Dfp, DfpDec use flags instead of exceptions
      • Fraction throws MathArithmeticException.

      There is a need for some cleaning up, which will proceed in two steps

      1. in the FieldElement interface the statement that an exception must be thrown will be removed. The rationale for this is that sometimes, an exception is actually not wanted. For example, I'm using a wrapper around primitive double, and I want all boundary cases to be handled exactly the same way as the primitive operation "/").
      2. the same exception (if any) will be thrown by all implementations. This will require to chose between ArithmeticException, MathArithmeticException and ZeroException.

        Attachments

          Activity

            People

            • Assignee:
              celestin Sebastien Brisard
              Reporter:
              celestin Sebastien Brisard
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: