C# 클래스 Nvelope.NumberExtensions

파일 보기 프로젝트 열기: TrinityWestern/Nvelope

공개 메소드들

메소드 설명
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