Qowaiv decimal rounding has three core benefits:
- Via an extension-method, the code is easier to follow.
- It supports a lot more rounding methods.
- It allows negative values for the amount of decimals (equivalent to multiple of ten, hundred, etc.).
public void Method(decimal value)
{
decimal floor = Math.Floor(value)
decimal ceiling = Math.Ceiling(value)
decimal truncate = Math.Truncate(value)
decimal rounded = Math.Round(value, 3, MidpointRouding.ToEven);
}
public void Method(decimal value)
{
decimal floor = value.Round(0, DecimalRounding.Floor);
decimal ceiling = value.Round(0, DecimalRounding.Ceiling);
decimal truncate = value.Round(0, DecimalRounding.Truncate);
decimal rounded = value.Round(3, DecimalRounding.ToEven);
}