public interface IObjectFloatEqualsAlmostCheck extends IObjectFloatEqualsAlmostCheckProperties, 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 |
isFloatEqualsAlmost(Object caller,
Float referenceA,
Float referenceB)
Checks if the referenced values are almost equals (B is within [L(A);U(A)]).
|
boolean |
isFloatEqualsAlmost(Object caller,
Float referenceA,
Float referenceB,
Float absoluteEpsilon)
Checks if the referenced values are almost equals (B is within [L(A);U(A)]).
|
boolean |
isFloatEqualsAlmost(Object caller,
Float referenceA,
Float referenceB,
Float absoluteEpsilon,
Float relativeEpsilon)
Checks if the referenced values are almost equals (B is within [L(A);U(A)]).
|
getFloatEqualsAlmostDefaultAbsoluteEpsilon, getFloatEqualsAlmostDefaultRelativeEpsilon, setFloatEqualsAlmostDefaultAbsoluteEpsilon, setFloatEqualsAlmostDefaultRelativeEpsilon
boolean isFloatEqualsAlmost(Object caller, Float referenceA, Float referenceB)
The default absolute epsilon is 0.00001f and the default relative epsilon is 0.000001f {link:IObjectFloatEqualsAlmostCheckProperties}.
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 isFloatEqualsAlmost(Object caller, Float referenceA, Float referenceB, Float absoluteEpsilon)
The default relative epsilon is 0.000001f {link:IObjectFloatEqualsAlmostCheckProperties}.
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 isFloatEqualsAlmost(Object caller, Float referenceA, Float referenceB, Float absoluteEpsilon, Float 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.