C# Class NExtends.Primitives.DoubleExtensions

Show file Open project: LuccaSA/NExtends

Public Methods

Method Description
Ceiling ( this d, int precision ) : Double
Floor ( this d, int precision ) : Double
RealRound ( this d, int precision ) : Double

Round number to given precision using mode MidpointRounding.AwayFromZero

ie: the normal maths rounding

For example: RealRound(0.165, 2) returns 0.17 and NOT 0.16

Round ( this d, int precision ) : Double

Round number to given precision using mode MidpointRounding.ToEven

If the one's digit is odd, it is changed to an even digit. Otherwise, it is left unchanged. This behavior follows IEEE Standard 754, section 4. It is sometimes called rounding to nearest, or banker's rounding. It minimizes rounding errors that result from consistently rounding a midpoint value in a single direction.

For example: Round(0.165, 2) returns 0.16 and NOT 0.17

More info on http://stackoverflow.com/questions/977796/in-c-math-round2-5-result-is-2-instead-of-3-are-you-kidding-me

ToJSON ( this d ) : String
tronquerDecimales ( this value ) : double

Method Details

Ceiling() public static method

public static Ceiling ( this d, int precision ) : Double
d this
precision int
return Double

Floor() public static method

public static Floor ( this d, int precision ) : Double
d this
precision int
return Double

RealRound() public static method

Round number to given precision using mode MidpointRounding.AwayFromZero

ie: the normal maths rounding

For example: RealRound(0.165, 2) returns 0.17 and NOT 0.16

public static RealRound ( this d, int precision ) : Double
d this
precision int
return Double

Round() public static method

Round number to given precision using mode MidpointRounding.ToEven

If the one's digit is odd, it is changed to an even digit. Otherwise, it is left unchanged. This behavior follows IEEE Standard 754, section 4. It is sometimes called rounding to nearest, or banker's rounding. It minimizes rounding errors that result from consistently rounding a midpoint value in a single direction.

For example: Round(0.165, 2) returns 0.16 and NOT 0.17

More info on http://stackoverflow.com/questions/977796/in-c-math-round2-5-result-is-2-instead-of-3-are-you-kidding-me

public static Round ( this d, int precision ) : Double
d this
precision int
return Double

ToJSON() public static method

public static ToJSON ( this d ) : String
d this
return String

tronquerDecimales() public static method

public static tronquerDecimales ( this value ) : double
value this
return double