Skip to content

Commit a948bab

Browse files
author
Karthik K
committed
updated the logic for ZeroErrorHandling #295
1 parent 7c52882 commit a948bab

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/main/java/edu/ie3/util/quantities/QuantityUtil.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@ public static <Q extends Quantity<Q>> boolean isEquivalentRel(Quantity<Q> a, Qua
134134
* of both quantities' value with regard to <i>{@code a}</i>'s value. Both quantities are
135135
* converted into <i>{@code a}</i>'s unit before the comparison.
136136
*
137-
* A special case for handling zero values is introduced:-
138-
* If {@code a} is 0 and {@code b} is also 0, the quantities are considered equivalent then returns true.
139-
* If {@code a} is 0 and {@code b} is not 0, the quantities are considered not equivalent then returns false.
137+
* <p>A special case for handling zero values is introduced:- If {@code a} is 0 and {@code b} is
138+
* also 0, the quantities are considered equivalent then returns true. If {@code a} is 0 and
139+
* {@code b} is not 0, the quantities are considered not equivalent then returns false.
140+
*
140141
* @param a First quantity to compare
141142
* @param b Second quantity to compare
142143
* @param relQuantityTolerance Permissible relative tolerance
@@ -150,7 +151,7 @@ public static <Q extends Quantity<Q>> boolean isEquivalentRel(
150151
double bVal = b.to(a.getUnit()).getValue().doubleValue();
151152

152153
if (aVal == 0.0) {
153-
return bVal == 0.0;
154+
return bVal == 0.0;
154155
}
155156

156157
return (Math.abs(aVal - bVal) / Math.abs(aVal)) <= relQuantityTolerance;

0 commit comments

Comments
 (0)