Skip to content

Commit 0b59139

Browse files
committed
solve build error, fix 'BigDecimal.equals()' spot bug
1 parent 2f89b98 commit 0b59139

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/com/thealgorithms/conversions/WordsToNumber.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static String convert(String numberInWords) {
8181

8282
while (!wordDeque.isEmpty()) {
8383
String word = wordDeque.poll();
84-
boolean currentChunkIsZero = currentChunk.equals(BigDecimal.ZERO);
84+
boolean currentChunkIsZero = currentChunk.compareTo(BigDecimal.ZERO) == 0;
8585

8686
boolean isConjunction = word.equals("and");
8787
if (isConjunction && isValidConjunction(prevNumWasHundred, prevNumWasPowerOfTen, wordDeque)) {
@@ -161,7 +161,7 @@ public static String convert(String numberInWords) {
161161
return "Invalid Input. " + (isConjunction ? "Unexpected 'and' placement" : "Unknown Word: " + word);
162162
}
163163

164-
if (!currentChunk.equals(BigDecimal.ZERO)) {
164+
if (!(currentChunk.compareTo(BigDecimal.ZERO) == 0)) {
165165
chunks.add(currentChunk);
166166
}
167167
BigDecimal completeNumber = combineChunks(chunks);

0 commit comments

Comments
 (0)