public class Utils extends Object
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static float |
EPSILON |
Indicates the epsilon used for comparing floating-point numbers.
|
| 构造器 | 说明 |
|---|---|
Utils() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
static boolean |
greatNotEqual(float left,
float right) |
Checks whether the left-hand-side floating-point number is greater than the right-hand-side floating-point
number.
|
static boolean |
greatOrEqual(float left,
float right) |
Checks whether the left-hand-side floating-point number is greater than or equal to the right-hand-side
floating-point number based on the default epsilon.
|
static boolean |
lessNotEqual(float left,
float right) |
Checks whether the left-hand-side floating-point number is less than the right-hand-side floating-point number.
|
static boolean |
lessOrEqual(float left,
float right) |
Checks whether the left-hand-side floating-point number is less than or equal to the right-hand-side
floating-point number based on the default epsilon.
|
static boolean |
nearEqual(float left,
float right) |
Checks whether two floating-point numbers are almost equal based on the default epsilon.
|
static boolean |
nearEqual(float left,
float right,
float epsilon) |
Checks whether two floating-point numbers are almost equal based on the specified epsilon.
|
static boolean |
nearZero(float left) |
Checks whether a floating-point number approximates to zero based on the default epsilon.
|
static boolean |
nearZero(float value,
float epsilon) |
Checks whether a floating-point number approximates to zero based on the specified epsilon.
|
public static final float EPSILON
public static boolean nearEqual(float left,
float right,
float epsilon)
left - Indicates the left-hand-side floating-point number to compare.right - Indicates the right-hand-side floating-point number to compare.epsilon - Indicates the epsilon for comparing the two floating-point numbers.true if the two floating-point numbers are almost equal; returns false otherwise.public static boolean nearZero(float value,
float epsilon)
value - Indicates the floating-point number to check.epsilon - Indicates the epsilon for checking the floating-point number.true if the floating-point number approximates to zero; returns false otherwise.public static boolean nearEqual(float left,
float right)
10^(-6).left - Indicates the left-hand-side floating-point number to compare.right - Indicates the right-hand-side floating-point number to compare.true if the two floating-point numbers are almost equal; returns false otherwise.public static boolean nearZero(float left)
10^(-6).left - Indicates the floating-point number to check.true if the floating-point number approximates to zero; returns false otherwise.public static boolean lessOrEqual(float left,
float right)
10^(-6).left - Indicates the left-hand-side floating-point number to compare.right - Indicates the right-hand-side floating-point number to compare.true if the left-hand-side floating-point number is less than or equal to the
right-hand-side floating-point number; returns false otherwise.public static boolean lessNotEqual(float left,
float right)
left - Indicates the left-hand-side floating-point number to compare.right - Indicates the right-hand-side floating-point number to compare.true if the left-hand-side floating-point number is less than the right-hand-side
floating-point number; returns false otherwise.public static boolean greatOrEqual(float left,
float right)
10^(-6).left - Indicates the left-hand-side floating-point number to compare.right - Indicates the right-hand-side floating-point number to compare.true if the left-hand-side floating-point number is greater than or equal to the
right-hand-side floating-point number; returns false otherwise.public static boolean greatNotEqual(float left,
float right)
left - Indicates the left-hand-side floating-point number to compare.right - Indicates the right-hand-side floating-point number to compare.true if the left-hand-side floating-point number is greater than the right-hand-side
floating-point number; returns false otherwise.