Table of Contents

Class PercentCalculator

Namespace
SunamoPercentCalculator
Assembly
SunamoPercentCalculator.dll

Calculator for percentage distribution. Typically called multiple times via DonePartially().

public class PercentCalculator
Inheritance
PercentCalculator
Inherited Members
Extension Methods

Constructors

PercentCalculator(double)

Creates a new instance of PercentCalculator with the specified overall sum.

public PercentCalculator(double overallSum)

Parameters

overallSum double

The total sum representing 100%.

Properties

Last

The last computed percentage value.

public double Last { get; set; }

Property Value

double

OnePercent

The value of one percent relative to the overall sum.

public double OnePercent { get; set; }

Property Value

double

OverallSum

The overall sum representing 100%.

public double OverallSum { get; set; }

Property Value

double

PercentCalculatorType

The type of this class, for reflection purposes.

public static Type PercentCalculatorType { get; set; }

Property Value

Type

Methods

AddOnePercent()

Adds one percent to the accumulated Last value.

public void AddOnePercent()

Create(double)

Creates a new PercentCalculator instance with the specified overall sum.

public static PercentCalculator Create(double overallSum)

Parameters

overallSum double

The total sum representing 100%.

Returns

PercentCalculator

A new PercentCalculator instance.

PercentFor(double, bool)

Calculates the percentage for a given value relative to the overall sum.

public int PercentFor(double value, bool isLast)

Parameters

value double

The value to calculate the percentage for.

isLast bool

Whether this is the last calculation, triggering adjustment to ensure total equals 100%.

Returns

int

The calculated percentage as an integer.

ResetComputedSum()

Resets the computed sum to zero. Automatically called by PercentFor when isLast is true.

public void ResetComputedSum()