spectre.console icon indicating copy to clipboard operation
spectre.console copied to clipboard

ProgressTask the calculation of GetPercantage can not handle division by 0

Open benzmarkus opened this issue 3 years ago • 2 comments

In my project the maxValue has 0 and the value is 0. The percentage calculation is then a division by 0 and the result percentage should be 0 too but it's -2,147,483,647

private double GetPercentage() { var percentage = (Value / MaxValue) * 100; percentage = Math.Min(100, Math.Max(0, percentage)); return percentage; }


Please upvote :+1: this issue if you are interested in it.

benzmarkus avatar Sep 29 '22 08:09 benzmarkus

I can work on fixing this

patrickfreilinger avatar Oct 04 '22 00:10 patrickfreilinger

Pull request is open here: https://github.com/spectreconsole/spectre.console/pull/991

patrickfreilinger avatar Oct 04 '22 04:10 patrickfreilinger