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

EPSILON value in org.apache.commons.math.util.MathUtils seems like half of what it should be

    XMLWordPrintableJSON

    Details

    • Type: Wish
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Won't Do
    • Affects Version/s: None
    • Fix Version/s: 4.X
    • Labels:
      None
    • Environment:

      win 7

    • Flags:
      Important

      Description

      I've always used 1.1920929E-7 for dealing with float epsilon values. When dealing with double I've always used 2.220446049250313E-16 for epsilon.

      You have it defined in org.apache.commons.math.util.MathUtils as 1.1102230246251565E-16 which is half what I think it should be.

      I come up with these numbers using the following:

      float fEps = Float.intBitsToFloat(Float.floatToIntBits(1f) + 1) - 1;
      double dEps = Double.longBitsToDouble(Double.doubleToLongBits(1) + 1) - 1;

      Am I correct? I don't really know. I do know that float epsilon in every legacy C/C++ compiler etc I have ever used is defined as about 1e-7 and this is the value using the formula for fEps above. When I started doing comps using doubles instead of floats I started using the formula for dEps above which looks to me like the equivalent for double numbers.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mccorb Brian S. McCormick
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified