Structure because structure
This commit is contained in:
parent
01d1ea3573
commit
2b2a53466f
17 changed files with 693 additions and 674 deletions
20
Tools/MathTools.cs
Normal file
20
Tools/MathTools.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
namespace Xorog.UniversalExtensions;
|
||||
|
||||
public static class MathTools
|
||||
{
|
||||
/// <summary>
|
||||
/// Calculates the percentage of the given 2 values.
|
||||
/// </summary>
|
||||
/// <param name="current">The current value.</param>
|
||||
/// <param name="max">The maximum value.</param>
|
||||
/// <returns>The percentage.</returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
public static int CalculatePercentage(double current, double max)
|
||||
{
|
||||
if (max == 0)
|
||||
throw new ArgumentException("Max cannot be zero.");
|
||||
|
||||
double percentage = (current / max) * 100;
|
||||
return Convert.ToInt32(percentage);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue