Better edge case check
Vladimir Bauer
9 years ago
| 513 | 513 |
}
|
| 514 | 514 |
|
| 515 | 515 |
func percentage(total, current int64, ratio int) int {
|
| 516 | |
if current > total || (total == 0 && current == 0) {
|
|
516 |
if total == 0 || current > total {
|
| 517 | 517 |
return 0
|
| 518 | 518 |
}
|
| 519 | 519 |
num := float64(ratio) * float64(current) / float64(total)
|