Skip to content

Percentages

This page is about the Percentages class available in PeyrSharp.Core.Maths. You can find here all of its methods.

INFO

This class is static.

Compatibility

The Percentages class is part of the PeyrSharp.Core module, which is compatible with all of these frameworks and platforms:

Package/PlatformWindowsmacOSLinux + others
Core
Framework.NET 6.NET 7.NET 8
Core

Methods

IncreaseBy(value, increaseRate)

Definition

Returns the value after an increase of x% as a double.

Arguments

TypeNameMeaning
doublevalueThe original value.
doubleincreaseRateThe increase percentage (as x/100d).

Usage

c#
using PeyrSharp.Core.Maths;

double price = Percentages.IncreaseBy(100, 10/100d); // Increase the price by 10%
// price = 110

DecreaseBy(value, decreaseRate)

Definition

Returns the value after a decrease of x% as a double.

Arguments

TypeNameMeaning
doublevalueThe original value.
doubledecreaseRateThe decrease percentage (as x/100d).

Usage

c#
using PeyrSharp.Core.Maths;

double price = Percentages.DecreaseBy(100, 10/100d); // Decrease the price by 10%
// price = 90

GetInvertedEvolutionRate(evolutionRate)

Definition

Gets the coefficient to get back to the original value after a percentage increase/decrease. It returns a double.

Arguments

TypeNameMeaning
doubleevolutionRateThe evolution rate to get the inverse of.

Usage

c#
using PeyrSharp.Core.Maths;

double ev = Percentages.GetInvertedEvolutionRate(1.1);
// ev = -0.09090909090909094

ProportionToPercentageString(proportion)

Definition

Formats a proportion to a string.

Arguments

TypeNameMeaning
doubleproportionThe proportion to get the percentage of.

Usage

c#
using PeyrSharp.Core.Maths;

double proportion = Percentages.ProportionToPercentageString(0.5);
// proportion = 50%

Released under the MIT License.