C# Class Redzen.Structures.Compact.FixedPointDecimal

A fixed point decimal data type that has the following qualities: 1) Uses a Int32 to hold the value (4 bytes versus the native decimal's 16 bytes). 2) Defines a fixed number of six digits after the decimal place. 3) Allows a null value to be represented, requiring a single bit to allocated for this. The range of FixedPointDecimal is -1,073.741823 to 1,073.741823. This can therefore represent all possible values in the SQL data type decimal(9,6). The range takes into into account the null bit and the fixed four digits after the decimal place. Fixed point maths also has the benefit of allowing for far simpler/faster comparison.
Show file Open project: colgreen/Redzen Class Usage Examples

Public Properties

Property Type Description
Null FixedPointDecimal

Public Methods

Method Description
Compare ( FixedPointDecimal d1, FixedPointDecimal d2 ) : int

Compares two specified FixedPointDecimal values.

Create ( decimal d ) : FixedPointDecimal

Static factory method to create a FixedDecimal.

Equals ( FixedPointDecimal d1, FixedPointDecimal d2 ) : bool

Determines whether the specified FixedPointDecimal is equal to the current FixedPointDecimal.

Equals ( object value ) : bool

Determines whether the specified Object is equal to the current Object.

FixedPointDecimal ( decimal val ) : System

Construct FixedPointDecimal from the provided nullable decimal.

GetHashCode ( ) : int

Gets the hash code for the object.

TryParse ( string s, FixedPointDecimal &result ) : bool

Converts the string representation of a number to its FixedPointDecimal equivalent. A return value indicates whether the conversion succeeded or failed.

TryParseTruncate ( string s, FixedPointDecimal &result ) : bool

Converts the string representation of a number to its FixedPointDecimal equivalent. A return value indicates whether the conversion succeeded or failed. Values outside the range of a FixedPointDecimal are truncated to the min or max values for FixedPointDecimal as appropriate. Input values with more than four decimal places have their precision truncated to to four decimal places.

operator ( ) : bool

Determines if two FixedPointDecimal objects are not equal.

Private Methods

Method Description
FixedPointDecimal ( uint significand, bool isNegative ) : System
InternalTryParse ( string s, FixedPointDecimal &result, bool truncateRange ) : bool

Method Details

Compare() public static method

Compares two specified FixedPointDecimal values.
public static Compare ( FixedPointDecimal d1, FixedPointDecimal d2 ) : int
d1 FixedPointDecimal The first to compare.
d2 FixedPointDecimal The second to compare.
return int

Create() public static method

Static factory method to create a FixedDecimal.
public static Create ( decimal d ) : FixedPointDecimal
d decimal The value to create the object from.
return FixedPointDecimal

Equals() public static method

Determines whether the specified FixedPointDecimal is equal to the current FixedPointDecimal.
public static Equals ( FixedPointDecimal d1, FixedPointDecimal d2 ) : bool
d1 FixedPointDecimal The first to compare.
d2 FixedPointDecimal The second to compare.
return bool

Equals() public method

Determines whether the specified Object is equal to the current Object.
public Equals ( object value ) : bool
value object The object to compare with the current object.
return bool

FixedPointDecimal() public method

Construct FixedPointDecimal from the provided nullable decimal.
public FixedPointDecimal ( decimal val ) : System
val decimal The value to convert.
return System

GetHashCode() public method

Gets the hash code for the object.
public GetHashCode ( ) : int
return int

TryParse() public static method

Converts the string representation of a number to its FixedPointDecimal equivalent. A return value indicates whether the conversion succeeded or failed.
public static TryParse ( string s, FixedPointDecimal &result ) : bool
s string The value to parse.
result FixedPointDecimal Upon success contains the equivalent of the value of .
return bool

TryParseTruncate() public static method

Converts the string representation of a number to its FixedPointDecimal equivalent. A return value indicates whether the conversion succeeded or failed. Values outside the range of a FixedPointDecimal are truncated to the min or max values for FixedPointDecimal as appropriate. Input values with more than four decimal places have their precision truncated to to four decimal places.
public static TryParseTruncate ( string s, FixedPointDecimal &result ) : bool
s string The value to parse.
result FixedPointDecimal Upon success contains the equivalent of the value of .
return bool

operator() public static method

Determines if two FixedPointDecimal objects are not equal.
public static operator ( ) : bool
return bool

Property Details

Null public static property

Public static instance of a null FixedPointDecimal.
public static FixedPointDecimal,Redzen.Structures.Compact Null
return FixedPointDecimal