Class Floats
- Since:
- 2.0.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final float
Epsilon that is used for comparison operations in this class. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
compare
(float left, float right) Gets an integer, that indicates the result of the comparison.static float
confined
(float low, float x, float high) Returns a float that is the confined value ofx
for two bounds.static boolean
equals
(float v1, float v2) Returnstrue
, if the values are equal.static boolean
lessThan
(float left, float right) Returnstrue
, is left comparand is less or equal to right comparand.static float
max3
(float v1, float v2, float v3) Gets a maximum float out of three values.static float
min3
(float v1, float v2, float v3) Gets a minumum float out of three values.static boolean
moreThan
(float left, float right) Returnstrue
, is left comparand is more or equal to right comparand.
-
Field Details
-
EPSILON
public static final float EPSILONEpsilon that is used for comparison operations in this class.EPSILON
is almost equal to zero, so all functions try to get zero and compare it to the epsilon.- Since:
- 2.0.0
- See Also:
-
-
Method Details
-
equals
public static boolean equals(float v1, float v2) Returnstrue
, if the values are equal.Uses epsilon for the comparison.
- Parameters:
v1
- first floatv2
- second float- Returns:
true
, if the values are equal;false
otherwise- Since:
- 2.0.0
-
moreThan
public static boolean moreThan(float left, float right) Returnstrue
, is left comparand is more or equal to right comparand.Uses epsilon for the comparison. Because of that, comparison is non-strict.
Should give the same result as
lessThan
with swapped comparands, if they are not equal. If they are equal, both functions should returntrue
.- Parameters:
left
- float to be comparedright
- float it is compared to- Returns:
true
, ifleft
is more than or equalsright
;false
otherwise- Since:
- 2.0.0
- See Also:
-
lessThan
public static boolean lessThan(float left, float right) Returnstrue
, is left comparand is less or equal to right comparand.Uses epsilon for the comparison. Because of that, comparison is non-strict.
Should give the same result as
moreThan
with swapped comparands, if they are not equal. If they are equal, both functions should returntrue
.- Parameters:
left
- float to be comparedright
- float it is compared to- Returns:
true
, ifleft
is less than or equalsright
;false
otherwise- Since:
- 2.0.0
- See Also:
-
compare
public static int compare(float left, float right) Gets an integer, that indicates the result of the comparison.If both values are equal, then 0 is returned.
If
left
is more thanright
, then 1 is returned.Otherwise, -1 is returned.
It does not function as shorthand syntax for
lessThan(float, float)
andmoreThan(float, float)
, because they are non-strict comparisons.- Parameters:
left
- float to be comparedright
- float it is compared to- Returns:
- 0, 1 or -1
- Since:
- 2.0.0
- See Also:
-
confined
public static float confined(float low, float x, float high) Returns a float that is the confined value ofx
for two bounds.If
x
is less thanlow
, thenlow
is returned.If
x
is more thanhigh
, thenhigh
is returned.Otherwise
x
is returned.- Parameters:
low
- lower boundx
- target float to confinehigh
- upper bound- Returns:
- confined float
- Since:
- 2.0.0
-
min3
public static float min3(float v1, float v2, float v3) Gets a minumum float out of three values.- Parameters:
v1
- first floatv2
- second floatv3
- third float- Returns:
- minimum float out of three values
- Since:
- 2.0.0
-
max3
public static float max3(float v1, float v2, float v3) Gets a maximum float out of three values.- Parameters:
v1
- first floatv2
- second floatv3
- third float- Returns:
- maximum float out of three values
- Since:
- 2.0.0
-