From 2c146c894972e2c6ab701b3c66dcf242d7be656f Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Tue, 24 Dec 2019 16:16:13 -0500 Subject: Added Javadoc to the project. --- doc/org/unitConverter/math/DecimalComparison.html | 492 ++++++++++++++++++++++ 1 file changed, 492 insertions(+) create mode 100644 doc/org/unitConverter/math/DecimalComparison.html (limited to 'doc/org/unitConverter/math/DecimalComparison.html') diff --git a/doc/org/unitConverter/math/DecimalComparison.html b/doc/org/unitConverter/math/DecimalComparison.html new file mode 100644 index 0000000..6b013fc --- /dev/null +++ b/doc/org/unitConverter/math/DecimalComparison.html @@ -0,0 +1,492 @@ + + + + + +DecimalComparison + + + + + + + + +
+ + + + + + + +
+ + + +
+
org.unitConverter.math
+

Class DecimalComparison

+
+
+ +
+
    +
  • +
    +
    +
    public final class DecimalComparison
    +extends java.lang.Object
    +
    A class that contains methods to compare float and double values.
    +
    +
    Since:
    +
    2019-03-18, v0.2.0
    +
    Author:
    +
    Adrien Hopkins
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Summary

      + + + + + + + + + + + + + + +
      Fields 
      Modifier and TypeField and Description
      static doubleDOUBLE_EPSILON +
      The value used for double comparison.
      +
      static floatFLOAT_EPSILON +
      The value used for float comparison.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethod and Description
      static booleanequals(double a, + double b) +
      Tests for equality of double values using DOUBLE_EPSILON.
      +
      static booleanequals(double a, + double b, + double epsilon) +
      Tests for double equality using a custom epsilon value.
      +
      static booleanequals(float a, + float b) +
      Tests for equality of float values using FLOAT_EPSILON.
      +
      static booleanequals(float a, + float b, + float epsilon) +
      Tests for float equality using a custom epsilon value.
      +
      static inthash(double d) +
      Takes the hash code of doubles.
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        DOUBLE_EPSILON

        +
        public static final double DOUBLE_EPSILON
        +
        The value used for double comparison. If two double values are within this value multiplied by the larger value, + they are considered equal.
        +
        +
        Since:
        +
        2019-03-18, v0.2.0
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      + + + +
        +
      • +

        FLOAT_EPSILON

        +
        public static final float FLOAT_EPSILON
        +
        The value used for float comparison. If two float values are within this value multiplied by the larger value, + they are considered equal.
        +
        +
        Since:
        +
        2019-03-18, v0.2.0
        +
        See Also:
        +
        Constant Field Values
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        equals

        +
        public static final boolean equals(double a,
        +                                   double b)
        +
        Tests for equality of double values using DOUBLE_EPSILON. +

        + WARNING: this method is not technically transitive. If a and b are off by slightly less than + epsilon * max(abs(a), abs(b)), and b and c are off by slightly less than + epsilon * max(abs(b), abs(c)), then equals(a, b) and equals(b, c) will both return true, but equals(a, c) + will return false. However, this situation is very unlikely to ever happen in a real programming situation. +

        + If this does become a concern, some ways to solve this problem: +

          +
        1. Raise the value of epsilon using equals(double, double, double) (this does not make a violation of + transitivity impossible, it just significantly reduces the chances of it happening) +
        2. Use BigDecimal instead of double (this will make a violation of transitivity 100% impossible) +
        +
        +
        Parameters:
        +
        a - first value to test
        +
        b - second value to test
        +
        Returns:
        +
        whether they are equal
        +
        Since:
        +
        2019-03-18, v0.2.0
        +
        See Also:
        +
        #hashCode(double)
        +
        +
      • +
      + + + +
        +
      • +

        equals

        +
        public static final boolean equals(double a,
        +                                   double b,
        +                                   double epsilon)
        +
        Tests for double equality using a custom epsilon value. + +

        + WARNING: this method is not technically transitive. If a and b are off by slightly less than + epsilon * max(abs(a), abs(b)), and b and c are off by slightly less than + epsilon * max(abs(b), abs(c)), then equals(a, b) and equals(b, c) will both return true, but equals(a, c) + will return false. However, this situation is very unlikely to ever happen in a real programming situation. +

        + If this does become a concern, some ways to solve this problem: +

          +
        1. Raise the value of epsilon (this does not make a violation of transitivity impossible, it just significantly + reduces the chances of it happening) +
        2. Use BigDecimal instead of double (this will make a violation of transitivity 100% impossible) +
        +
        +
        Parameters:
        +
        a - first value to test
        +
        b - second value to test
        +
        epsilon - allowed difference
        +
        Returns:
        +
        whether they are equal
        +
        Since:
        +
        2019-03-18, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        equals

        +
        public static final boolean equals(float a,
        +                                   float b)
        +
        Tests for equality of float values using FLOAT_EPSILON. + +

        + WARNING: this method is not technically transitive. If a and b are off by slightly less than + epsilon * max(abs(a), abs(b)), and b and c are off by slightly less than + epsilon * max(abs(b), abs(c)), then equals(a, b) and equals(b, c) will both return true, but equals(a, c) + will return false. However, this situation is very unlikely to ever happen in a real programming situation. +

        + If this does become a concern, some ways to solve this problem: +

          +
        1. Raise the value of epsilon using equals(float, float, float) (this does not make a violation of + transitivity impossible, it just significantly reduces the chances of it happening) +
        2. Use BigDecimal instead of float (this will make a violation of transitivity 100% impossible) +
        +
        +
        Parameters:
        +
        a - first value to test
        +
        b - second value to test
        +
        Returns:
        +
        whether they are equal
        +
        Since:
        +
        2019-03-18, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        equals

        +
        public static final boolean equals(float a,
        +                                   float b,
        +                                   float epsilon)
        +
        Tests for float equality using a custom epsilon value. + +

        + WARNING: this method is not technically transitive. If a and b are off by slightly less than + epsilon * max(abs(a), abs(b)), and b and c are off by slightly less than + epsilon * max(abs(b), abs(c)), then equals(a, b) and equals(b, c) will both return true, but equals(a, c) + will return false. However, this situation is very unlikely to ever happen in a real programming situation. +

        + If this does become a concern, some ways to solve this problem: +

          +
        1. Raise the value of epsilon (this does not make a violation of transitivity impossible, it just significantly + reduces the chances of it happening) +
        2. Use BigDecimal instead of float (this will make a violation of transitivity 100% impossible) +
        +
        +
        Parameters:
        +
        a - first value to test
        +
        b - second value to test
        +
        epsilon - allowed difference
        +
        Returns:
        +
        whether they are equal
        +
        Since:
        +
        2019-03-18, v0.2.0
        +
        +
      • +
      + + + +
        +
      • +

        hash

        +
        public static final int hash(double d)
        +
        Takes the hash code of doubles. Values that are equal according to equals(double, double) will have the + same hash code.
        +
        +
        Parameters:
        +
        d - double to hash
        +
        Returns:
        +
        hash code of double
        +
        Since:
        +
        2019-10-16
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + -- cgit v1.2.3