Skip to content

Commit

Permalink
Allowing "0/0" to == 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
handstandsam committed Jan 24, 2025
1 parent ef59366 commit e03f5ad
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ object MathUtils {
}

fun percentage(amount: Int, total: Int): Double {
return if (amount == 0 || total == 0) {
return if (amount == 0 && total == 0) {
100.0
} else if (amount == 0) {
0.0
} else {
roundToDecimal(amount / total.toDouble() * 100)
Expand Down

0 comments on commit e03f5ad

Please sign in to comment.