Skip to content

Commit

Permalink
refactor: totalCount가 0이면 0 리턴하도록 변경 #208
Browse files Browse the repository at this point in the history
  • Loading branch information
PgmJun committed Aug 20, 2024
1 parent e7e2040 commit ef75936
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class PercentageCalculator {

private static final double SECOND_DECIMAL_PLACE_ROUNDING_FACTOR = 100.0;
private static final int DEFAULT_PERCENTAGE = 50;
private static final int NON_TOTAL_COUNT_PERCENTAGE = 0;

public static int calculatePercent(long count, long totalCount) {
if (count < 0) {
Expand All @@ -19,7 +19,7 @@ public static int calculatePercent(long count, long totalCount) {
}

if (totalCount == 0) {
return DEFAULT_PERCENTAGE;
return NON_TOTAL_COUNT_PERCENTAGE;
}
return (int) Math.round(count * SECOND_DECIMAL_PLACE_ROUNDING_FACTOR / totalCount);
}
Expand Down

0 comments on commit ef75936

Please sign in to comment.