public interface IObjectDoubleEqualsAlmostCheck extends IObjectDoubleEqualsAlmostCheckProperties, ICheck
This is an attempt on an equals check that supports both tiny numbers with an absolute epsilon test and large numbers with a relative epsilon test.
The idea behind this is to find a lower-function - L(X) - and upper-function - U(X) - that for any X tells in which range Y is considered almost equal to X
For an absolute epsilon: L(X) = X - EPSILON_abs, U(x) = X + EPSILON_abs For a relative epsilon: L(X) = (1 - Sign(X) * EPSILON_rel) * X, U(X) = (1 + Sign(X) * EPSILON_rel) * X (see https://github.com/KeldOelykke/FailFast/blob/master/Java/Docs/Images/absAndRelErrorFunctions.png).
Above combined gives: L(X) = (1 - Sign(X) * EPSILON_rel) * X - EPSILON_abs, U(x) = (1 + Sign(X) * EPSILON_rel) * X + EPSILON_abs (see https://github.com/KeldOelykke/FailFast/blob/master/Java/Docs/Images/almostEqualZoneForXandY.png).
Modifier and Type | Method and Description |
---|---|
boolean |
isDoubleEqualsAlmost(Object caller,
Double referenceA,
Double referenceB)
Checks if the referenced values are almost equals (B is within [L(A);U(A)]).
|
boolean |
isDoubleEqualsAlmost(Object caller,
Double referenceA,
Double referenceB,
Double absoluteEpsilon)
Checks if the referenced values are almost equals (B is within [L(A);U(A)]).
|
boolean |
isDoubleEqualsAlmost(Object caller,
Double referenceA,
Double referenceB,
Double absoluteEpsilon,
Double relativeEpsilon)
Checks if the referenced values are almost equals (B is within [L(A);U(A)]).
|
getDoubleEqualsAlmostDefaultAbsoluteEpsilon, getDoubleEqualsAlmostDefaultRelativeEpsilon, setDoubleEqualsAlmostDefaultAbsoluteEpsilon, setDoubleEqualsAlmostDefaultRelativeEpsilon
boolean isDoubleEqualsAlmost(Object caller, Double referenceA, Double referenceB)
The default absolute epsilon is 0.00001 and the default relative epsilon is 0.000001 {link:IObjectDoubleEqualsAlmostCheckProperties}.
caller
- end-user instance initiating the checkreferenceA
- reference to equals check against reference BreferenceB
- argument to equals-method of reference AIllegalArgumentException
- if caller is nullboolean isDoubleEqualsAlmost(Object caller, Double referenceA, Double referenceB, Double absoluteEpsilon)
The default relative epsilon is 0.000001 {link:IObjectDoubleEqualsAlmostCheckProperties}.
caller
- end-user instance initiating the checkreferenceA
- reference to equals check against reference BreferenceB
- argument to equals-method of reference AabsoluteEpsilon
- disregarded absolute difference between A and BIllegalArgumentException
- if caller is nullboolean isDoubleEqualsAlmost(Object caller, Double referenceA, Double referenceB, Double absoluteEpsilon, Double relativeEpsilon)
caller
- end-user instance initiating the checkreferenceA
- reference to equals check against reference BreferenceB
- argument to equals-method of reference AabsoluteEpsilon
- disregarded absolute difference between A and BrelativeEpsilon
- disregarded relative difference between A and BIllegalArgumentException
- if caller is nullThe MIT License (MIT) - Copyright © 2014-2015 Keld Oelykke. All Rights Reserved.