public class UlpDistanceBound extends Object implements FloatingPointTolerance
The ULP is based on the representation of the values rather than the values itself. As errors in single- and double-precision floating point arithmetic stem from the inability to precisely represent values, measuring the distance in ULPs can provide a bound which is more consistent in behavior, regardless of the the scale of the the values.
As the ULP is based on the IEEE 754 specification for floating point, this tolerance is not supported for BigDecimal.
EXACT
Constructor and Description |
---|
UlpDistanceBound(int maxUlps)
Define a fixed bound on the distance between two floating
point values, measured in ULPs.
|
Modifier and Type | Method and Description |
---|---|
int |
getMaxUlps()
Gets the maximum number of ULPs allowed between two values.
|
boolean |
isWithinTolerance(BigDecimal value1,
BigDecimal value2)
Indicates whether the specified values are equal under the tolerance.
|
boolean |
isWithinTolerance(double value1,
double value2)
Indicates whether the specified values are equal under the tolerance.
|
boolean |
isWithinTolerance(float value1,
float value2)
Indicates whether the specified values are equal under the tolerance.
|
public UlpDistanceBound(int maxUlps)
maxUlps
- the fixed bound on the distance, in ULPScom.pervasive.datarush.graphs.physical.InvalidPropertyValueException
- if epsilon
is
negative.public boolean isWithinTolerance(float value1, float value2)
FloatingPointTolerance
isWithinTolerance
in interface FloatingPointTolerance
value1
- the first value to comparevalue2
- the second value to comparetrue
if the two values lie with the error bounds,
otherwise false
public boolean isWithinTolerance(double value1, double value2)
FloatingPointTolerance
isWithinTolerance
in interface FloatingPointTolerance
value1
- the first value to comparevalue2
- the second value to comparetrue
if the two values lie with the error bounds,
otherwise false
public boolean isWithinTolerance(BigDecimal value1, BigDecimal value2)
ULP based tolerance is not supported for BigDecimal
values.
isWithinTolerance
in interface FloatingPointTolerance
value1
- the first value to comparevalue2
- the second value to comparetrue
if the two values lie with the error bounds,
otherwise false
public int getMaxUlps()
Copyright © 2016 Actian Corporation. All rights reserved.