C# Класс Nvelope.NumberExtensions

Показать файл Открыть проект

Открытые методы

Метод Описание
AsPercentage ( this rate ) : string

Formats a rate as a percentage.

DivDown ( this a, int b ) : int

Integer division that always rounds down Equivilant to a/b in many languages. It complements the modulo operation.

GreaterOf ( int first, int second ) : int

Returns the passed-in value that is greatest. If both values are the same returns the first

Inc ( this start, int increment = 1 ) : IEnumerable

Starting at start, generate an infinite sequence of numbers, incrementing by increment. WARNING: Generates an infinite (or nearly infinite) sequence, so call Take() on this or something, or your program will be here forever.

IsAbout ( this number, decimal other, decimal precision ) : bool

Is number the same as other, to within precision ie, 1.01m.IsAbout(1.0m, .1m) means "is 1.01 equal 1.0 to within .1?"

IsEven ( this num ) : bool
IsOdd ( this num ) : bool
LesserOf ( int first, int second ) : int

Returns the passed-in value that is smallest. If both values are the same returns the first

Mod ( this a, int b ) : int

The integer modulo where the divisor's sign is maintained, not the the dividends. If the dividend's sign is maintained, it is typically called the remainder. For example, (-3).Mod(5) == 2, this is different from the `%` in C#.

PrintDecimal ( this o ) : string
RoundTo ( this number, int decimalPlaces, MidpointRounding roundingRule = MidpointRounding.AwayFromZero ) : decimal

A wrapper around Decimal.Round

Times ( this num, System.Action action ) : void

Perform some action num times

To ( this start, int end, int increment = null ) : IEnumerable

Get a list of numbers from start to end (inclusive), incrementing by increment

ToOrdinal ( this i ) : string

Converts 1 to 1st, 2 to 2nd, etc

Описание методов

AsPercentage() публичный статический Метод

Formats a rate as a percentage.
public static AsPercentage ( this rate ) : string
rate this The rate specified as decimal.
Результат string

DivDown() публичный статический Метод

Integer division that always rounds down Equivilant to a/b in many languages. It complements the modulo operation.
public static DivDown ( this a, int b ) : int
a this
b int
Результат int

GreaterOf() публичный статический Метод

Returns the passed-in value that is greatest. If both values are the same returns the first
public static GreaterOf ( int first, int second ) : int
first int
second int
Результат int

Inc() публичный статический Метод

Starting at start, generate an infinite sequence of numbers, incrementing by increment. WARNING: Generates an infinite (or nearly infinite) sequence, so call Take() on this or something, or your program will be here forever.
public static Inc ( this start, int increment = 1 ) : IEnumerable
start this
increment int
Результат IEnumerable

IsAbout() публичный статический Метод

Is number the same as other, to within precision ie, 1.01m.IsAbout(1.0m, .1m) means "is 1.01 equal 1.0 to within .1?"
public static IsAbout ( this number, decimal other, decimal precision ) : bool
number this
other decimal
precision decimal
Результат bool

IsEven() публичный статический Метод

public static IsEven ( this num ) : bool
num this
Результат bool

IsOdd() публичный статический Метод

public static IsOdd ( this num ) : bool
num this
Результат bool

LesserOf() публичный статический Метод

Returns the passed-in value that is smallest. If both values are the same returns the first
public static LesserOf ( int first, int second ) : int
first int
second int
Результат int

Mod() публичный статический Метод

The integer modulo where the divisor's sign is maintained, not the the dividends. If the dividend's sign is maintained, it is typically called the remainder. For example, (-3).Mod(5) == 2, this is different from the `%` in C#.
public static Mod ( this a, int b ) : int
a this
b int
Результат int

PrintDecimal() публичный статический Метод

public static PrintDecimal ( this o ) : string
o this
Результат string

RoundTo() публичный статический Метод

A wrapper around Decimal.Round
public static RoundTo ( this number, int decimalPlaces, MidpointRounding roundingRule = MidpointRounding.AwayFromZero ) : decimal
number this
decimalPlaces int
roundingRule MidpointRounding
Результат decimal

Times() публичный статический Метод

Perform some action num times
public static Times ( this num, System.Action action ) : void
num this
action System.Action
Результат void

To() публичный статический Метод

Get a list of numbers from start to end (inclusive), incrementing by increment
public static To ( this start, int end, int increment = null ) : IEnumerable
start this
end int
increment int defaults to 1 or -1
Результат IEnumerable

ToOrdinal() публичный статический Метод

Converts 1 to 1st, 2 to 2nd, etc
public static ToOrdinal ( this i ) : string
i this
Результат string