Package org.eclipse.gef.geometry.internal.utils

## Class PrecisionUtils

- java.lang.Object
- - org.eclipse.gef.geometry.internal.utils.PrecisionUtils

    public class PrecisionUtils
    extends java.lang.Object

A utility class for floating point calculations and comparisons that should guarantee a precision of a given scale, and ignore differences beyond this scale.

### Method Summary

All Methods Static Methods Concrete Methods
`static double` `calculateFraction​(int shift)` Computes the smallest double that is yet recognizable (by comparison) when shifting the default scale up by the given amount.
`static boolean` `equal​(double d1, double d2)`
`static boolean` `equal​(double d1, double d2, int shift)` Tests whether the two values are regarded to be equal w.r.t. the given shift.
`static boolean` `greater​(double d1, double d2)`
`static boolean` `greater​(double d1, double d2, int shift)` Tests whether the first given value is regarded to be greater than the second value w.r.t. the given shift.
`static boolean` `greaterEqual​(double d1, double d2)`
`static boolean` `greaterEqual​(double d1, double d2, int shift)` Tests whether the first given value is regarded to be greater or equal than the second value w.r.t. the given shift.
`static boolean` `smaller​(double d1, double d2)`
`static boolean` `smaller​(double d1, double d2, int shift)` Tests whether the first given value is regarded to be smaller than the second value w.r.t. the given shift.
`static boolean` `smallerEqual​(double d1, double d2)`
`static boolean` `smallerEqual​(double d1, double d2, int shift)` Tests whether the first given value is regarded to be smaller or equal than the second value w.r.t. the given shift.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### calculateFraction

    public static final double calculateFraction​(int shift)

Computes the smallest double that is yet recognizable (by comparison) when shifting the default scale up by the given amount.

Parameters:
  `shift` - the number of digits to shift precision up (may be negative number)
Returns:
  the smallest double that will yet be recognizable by the methods of this class during comparison, when using the default scale shifted by the given amount.

#### equal

    public static final boolean equal​(double d1,
                                      double d2)

Parameters:
  `d1` - The first operand.
  `d2` - The second operand.
Returns:
  result of the comparison
See Also:
  `equal(double, double, int)`

#### equal

    public static final boolean equal​(double d1,
                                      double d2,
                                      int shift)

Tests whether the two values are regarded to be equal w.r.t. the given shift.

Parameters:
  `d1` - the first value to test
  `d2` - the second value to test
  `shift` - the delta shift used for this test
Returns:
  `true` in case the given two values are identical or differ from each other by an amount that is smaller than what is recognizable by the shifted delta, `false` otherwise

#### greater

    public static final boolean greater​(double d1,
                                        double d2)

Parameters:
  `d1` - The first operand.
  `d2` - The second operand.
Returns:
  result of the comparison
See Also:
  `greater(double, double, int)`

#### greater

    public static final boolean greater​(double d1,
                                        double d2,
                                        int shift)

Tests whether the first given value is regarded to be greater than the second value w.r.t. the given shift.

Parameters:
  `d1` - the first value to test
  `d2` - the second value to test
  `shift` - the delta shift used for this test
Returns:
  `true` in case the first value is greater than the second value by an amount recognizable by the shifted delta, `false` otherwise

#### greaterEqual

    public static final boolean greaterEqual​(double d1,
                                             double d2)

Parameters:
  `d1` - The first operand.
  `d2` - The second operand.
Returns:
  result of the comparison
See Also:
  `greaterEqual(double, double, int)`

#### greaterEqual

    public static final boolean greaterEqual​(double d1,
                                             double d2,
                                             int shift)

Tests whether the first given value is regarded to be greater or equal than the second value w.r.t. the given shift.

Parameters:
  `d1` - the first value to test
  `d2` - the second value to test
  `shift` - the delta shift used for this test
Returns:
  `true` in case the first value is greater than the second value by an amount recognizable by the given scale or differs from it by an amount not recognizable by the shifted delta, `false` otherwise

#### smaller

    public static final boolean smaller​(double d1,
                                        double d2)

Parameters:
  `d1` - The first operand.
  `d2` - The second operand.
Returns:
  result of the comparison
See Also:
  `smaller(double, double, int)`

#### smaller

    public static final boolean smaller​(double d1,
                                        double d2,
                                        int shift)

Tests whether the first given value is regarded to be smaller than the second value w.r.t. the given shift.

Parameters:
  `d1` - the first value to test
  `d2` - the second value to test
  `shift` - the delta shift used for this test
Returns:
  `true` in case the first value is smaller than the second value by an amount recognizable by the shifted delta, `false` otherwise

#### smallerEqual

    public static final boolean smallerEqual​(double d1,
                                             double d2)

Parameters:
  `d1` - The first operand.
  `d2` - The second operand.
Returns:
  result of the comparison
See Also:
  `smallerEqual(double, double, int)`

#### smallerEqual

    public static final boolean smallerEqual​(double d1,
                                             double d2,
                                             int shift)

Tests whether the first given value is regarded to be smaller or equal than the second value w.r.t. the given shift.

Parameters:
  `d1` - the first value to test
  `d2` - the second value to test
  `shift` - the delta shift used for this test
Returns:
  `true` in case the first value is smaller than the second value by an amount recognizable by the given scale or differs from it by an amount not recognizable by the shifted delta, `false` otherwise