namespace Xorog.UniversalExtensions;
public static class MathTools
{
///
/// Calculates the percentage of the given 2 values.
///
/// The current value.
/// The maximum value.
/// The percentage.
///
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);
}
}