C# Class Nvelope.NumberExtensions

Afficher le fichier Open project: TrinityWestern/Nvelope

Méthodes publiques

Méthode Description
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

Method Details

AsPercentage() public static méthode

Formats a rate as a percentage.
public static AsPercentage ( this rate ) : string
rate this The rate specified as decimal.
Résultat string

DivDown() public static méthode

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
Résultat int

GreaterOf() public static méthode

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
Résultat int

Inc() public static méthode

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
Résultat IEnumerable

IsAbout() public static méthode

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
Résultat bool

IsEven() public static méthode

public static IsEven ( this num ) : bool
num this
Résultat bool

IsOdd() public static méthode

public static IsOdd ( this num ) : bool
num this
Résultat bool

LesserOf() public static méthode

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
Résultat int

Mod() public static méthode

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
Résultat int

PrintDecimal() public static méthode

public static PrintDecimal ( this o ) : string
o this
Résultat string

RoundTo() public static méthode

A wrapper around Decimal.Round
public static RoundTo ( this number, int decimalPlaces, MidpointRounding roundingRule = MidpointRounding.AwayFromZero ) : decimal
number this
decimalPlaces int
roundingRule MidpointRounding
Résultat decimal

Times() public static méthode

Perform some action num times
public static Times ( this num, System.Action action ) : void
num this
action System.Action
Résultat void

To() public static méthode

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
Résultat IEnumerable

ToOrdinal() public static méthode

Converts 1 to 1st, 2 to 2nd, etc
public static ToOrdinal ( this i ) : string
i this
Résultat string