Class DecimalExtensions
Decimal extension methods
Inherited Members
Namespace: PayrollEngine.Client.Scripting
Assembly: PayrollEngine.Client.Scripting.dll
Syntax
public static class DecimalExtensions
Methods
View SourceIsWithin(decimal, decimal, decimal)
Determines whether a value is within a range
Declaration
public static bool IsWithin(this decimal value, decimal min, decimal max)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal | value | The value to test |
| decimal | min | The minimum value |
| decimal | max | The maximum value |
Returns
| Type | Description |
|---|---|
| bool | True if the specified value is within minimum and maximum |
IsWithin(decimal?, decimal, decimal)
Determines whether a value is within a range
Declaration
public static bool IsWithin(this decimal? value, decimal min, decimal max)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal? | value | The value to test |
| decimal | min | The minimum value |
| decimal | max | The maximum value |
Returns
| Type | Description |
|---|---|
| bool | True if the specified value is within minimum and maximum |
Round(decimal, DecimalRounding)
Rounds a decimal value wit predefined rounding type
Declaration
public static decimal Round(this decimal value, DecimalRounding rounding)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal | value | |
| DecimalRounding | rounding | The rounding type |
Returns
| Type | Description |
|---|---|
| decimal | The rounded value |
RoundDown(decimal, decimal)
Rounds a decimal value down
Declaration
public static decimal RoundDown(this decimal value, decimal stepSize)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal | value | |
| decimal | stepSize | The round step size |
Returns
| Type | Description |
|---|---|
| decimal | The rounded value |
RoundFifth(decimal)
Rounds a decimal value to a one-fifth (e.g. 20 cents)
Declaration
public static decimal RoundFifth(this decimal value)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal | value |
Returns
| Type | Description |
|---|---|
| decimal | The rounded value to one-fifth |
RoundFiftieth(decimal)
Rounds a decimal value to a one-fiftieth (e.g. 2 cents)
Declaration
public static decimal RoundFiftieth(this decimal value)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal | value |
Returns
| Type | Description |
|---|---|
| decimal | The rounded value to one-fiftieth |
RoundHalf(decimal)
Rounds a decimal value to a one-half (e.g. 50 cents)
Declaration
public static decimal RoundHalf(this decimal value)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal | value |
Returns
| Type | Description |
|---|---|
| decimal | The rounded value to one-half |
RoundHundredth(decimal)
Rounds a decimal value to a one-hundredth (e.g. 1 cents)
Declaration
public static decimal RoundHundredth(this decimal value)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal | value |
Returns
| Type | Description |
|---|---|
| decimal | The rounded value to one-hundredth |
RoundPartOfOne(decimal, int)
Rounds a decimal value to a one-tenth
Declaration
public static decimal RoundPartOfOne(this decimal value, int divisor)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal | value | |
| int | divisor | The divisor factor |
Returns
| Type | Description |
|---|---|
| decimal | The rounded value to one-tenth |
RoundTenth(decimal)
Rounds a decimal value to a one-tenth (e.g. 10 cents)
Declaration
public static decimal RoundTenth(this decimal value)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal | value |
Returns
| Type | Description |
|---|---|
| decimal | The rounded value to one-tenth |
RoundTwentieth(decimal)
Rounds a decimal value to a one-twentieth (e.g. 5 cents)
Declaration
public static decimal RoundTwentieth(this decimal value)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal | value |
Returns
| Type | Description |
|---|---|
| decimal | The rounded value to one-twentieth |
RoundUp(decimal, decimal)
Rounds a decimal value up
Declaration
public static decimal RoundUp(this decimal value, decimal stepSize)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal | value | |
| decimal | stepSize | The round step size |
Returns
| Type | Description |
|---|---|
| decimal | The up-rounded value |
Truncate(decimal, int)
Returns the integral digits of the specified decimal, using a step size
Declaration
public static decimal Truncate(this decimal value, int stepSize)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal | value | |
| int | stepSize | The step size used to truncate |
Returns
| Type | Description |
|---|---|
| decimal | The result of d rounded toward zero, to the nearest whole number within the step size |