spectreconsole / spectre.console

A .NET library that makes it easier to create beautiful console applications.
https://spectreconsole.net
MIT License
9.17k stars 472 forks source link

ProgressTask the calculation of GetPercantage can not handle division by 0 #981

Open benzmarkus opened 1 year ago

benzmarkus commented 1 year ago

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.

patrickfreilinger commented 1 year ago

I can work on fixing this

patrickfreilinger commented 1 year ago

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