Public Types

typedef Detail::decimal_number_type number_type
 An alias for Detail::decimal_number_type. More...
 

Public Member Functions

 Decimal ()
 Constructs an intsance that represents 0. More...
 
 Decimal (std::int8_t i)
 
 Decimal (std::int16_t i)
 
 Decimal (std::int32_t i)
 
 Decimal (std::int64_t i)
 
 Decimal (std::uint8_t i)
 
 Decimal (std::uint16_t i)
 
 Decimal (std::uint32_t i)
 
 Decimal (std::uint64_t i)
 
 Decimal (float f)
 
 Decimal (double d)
 
 Decimal (std::nullptr_t)
 Constructs an instance that represents 0. More...
 
 Decimal (const std::string &str)
 Constructs an instance that represents a value whose string representation is specified as an instance of std::string class. More...
 
 Decimal (const String &str)
 Constructs an instance that represents a value whose string representation is specified as an instance of String class. More...
 
 Decimal (int32_t lo, int32_t mid, int32_t hi, bool isNegative, uint8_t scale)
 
 Decimal (const Decimal &d)
 
 ~Decimal ()
 Destructor. More...
 
Decimaloperator= (const Decimal &d)
 
 operator float () const
 Converts the value represented by the current object to single-precision floating-point value. More...
 
 operator double () const
 Converts the value represented by the current object to double-precision floating-point value. More...
 
 operator bool () const
 
Decimal operator+ (const Decimal &d) const
 
Decimal operator- (const Decimal &d) const
 
Decimal operator* (const Decimal &d) const
 
Decimal operator/ (const Decimal &d) const
 
Decimal operator% (const Decimal &d) const
 
Decimal operator- () const
 Returns a new instance of Decimal class that represents a value that results from negation of the value represented by the current object. More...
 
bool operator== (const Decimal &d) const
 
bool operator!= (const Decimal &d) const
 
bool operator== (std::nullptr_t) const
 
bool operator!= (std::nullptr_t) const
 
bool operator< (const Decimal &d) const
 
bool operator<= (const Decimal &d) const
 
bool operator> (const Decimal &d) const
 
bool operator>= (const Decimal &d) const
 
Decimaloperator++ ()
 
Decimaloperator-- ()
 
Decimaloperator+= (const Decimal &d)
 
Decimaloperator-= (const Decimal &d)
 
Decimaloperator*= (const Decimal &d)
 
Decimaloperator/= (const Decimal &d)
 
Decimaloperator%= (const Decimal &d)
 
bool Equals (const Decimal &d) const
 
int CompareTo (const Decimal &d) const
 
int GetHashCode () const
 Returns a hash code for the current object. More...
 
String ToString () const
 Returns the string representation of the value represented by the object. More...
 
std::string ToStdString () const
 Returns an instance of std::string that contains the string representation of the value represented by the object. More...
 
 Decimal (const number_type &value)
 

Static Public Member Functions

static Decimal Round (Decimal d, MidpointRounding mode=MidpointRounding::ToEven)
 
static Decimal Round (Decimal d, int digits, MidpointRounding mode=MidpointRounding::ToEven)
 
static Decimal Truncate (Decimal d)
 
static Decimal Ceiling (Decimal d)
 
static Decimal Floor (Decimal d)
 
static bool Equals (Decimal d1, Decimal d2)
 
static int Compare (Decimal d1, Decimal d2)
 
static Decimal Parse (const String &str)
 
static Decimal Parse (const String &s, System::Globalization::NumberStyles style)
 
static const TypeInfoType ()
 Returns a reference to the TypeInfo object representing the Decimal class' type information. More...
 
static System::ArrayPtr< int > GetBits (Decimal d)
 
static void GetBytes (Decimal value, const System::ArrayPtr< uint8_t > &buffer)
 

Static Public Attributes

static const Decimal ASPOSECPP_SHARED_API MaxValue
 Represents the largest number that can be represented by Decimal class. More...
 
static const Decimal ASPOSECPP_SHARED_API MinValue
 Represents the smallest number that can be represented by Decimal class. More...
 
static const Decimal ASPOSECPP_SHARED_API MinusOne
 Represents number -1. More...
 
static const Decimal ASPOSECPP_SHARED_API One
 Represets number 1. More...
 
static const Decimal ASPOSECPP_SHARED_API Zero
 Represents number 0. More...
 

Detailed Description

Represents a decimal number. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type.

Member Typedef Documentation

◆ number_type

typedef Detail::decimal_number_type System::Decimal::number_type

An alias for Detail::decimal_number_type.

Constructor & Destructor Documentation

◆ Decimal() [1/17]

System::Decimal::Decimal ( )

Constructs an intsance that represents 0.

◆ Decimal() [2/17]

System::Decimal::Decimal ( std::int8_t  i)

Consstructs an instance that represents the specified value.

Parameters
i8-bit integer value to be represented by the Decimal object being constructed

◆ Decimal() [3/17]

System::Decimal::Decimal ( std::int16_t  i)

Consstructs an instance that represents the specified value.

Parameters
i16-bit integer value to be represented by the Decimal object being constructed

◆ Decimal() [4/17]

System::Decimal::Decimal ( std::int32_t  i)

Consstructs an instance that represents the specified value.

Parameters
i32-bit integer value to be represented by the Decimal object being constructed

◆ Decimal() [5/17]

System::Decimal::Decimal ( std::int64_t  i)

Consstructs an instance that represents the specified value.

Parameters
i64-bit integer value to be represented by the Decimal object being constructed

◆ Decimal() [6/17]

System::Decimal::Decimal ( std::uint8_t  i)

Consstructs an instance that represents the specified value.

Parameters
iunsigned 8-bit integer value to be represented by the Decimal object being constructed

◆ Decimal() [7/17]

System::Decimal::Decimal ( std::uint16_t  i)

Consstructs an instance that represents the specified value.

Parameters
iunsigned 16-bit integer value to be represented by the Decimal object being constructed

◆ Decimal() [8/17]

System::Decimal::Decimal ( std::uint32_t  i)

Consstructs an instance that represents the specified value.

Parameters
iunsigned 32-bit integer value to be represented by the Decimal object being constructed

◆ Decimal() [9/17]

System::Decimal::Decimal ( std::uint64_t  i)

Consstructs an instance that represents the specified value.

Parameters
iunsigned 64-bit integer value to be represented by the Decimal object being constructed

◆ Decimal() [10/17]

System::Decimal::Decimal ( float  f)

Consstructs an instance that represents the specified value.

Parameters
fThe single-precision floating-point value to be represented by the Decimal object being constructed

◆ Decimal() [11/17]

System::Decimal::Decimal ( double  d)

Consstructs an instance that represents the specified value.

Parameters
dThe double-precision floating-point value to be represented by the Decimal object being constructed

◆ Decimal() [12/17]

System::Decimal::Decimal ( std::nullptr_t  )

Constructs an instance that represents 0.

◆ Decimal() [13/17]

System::Decimal::Decimal ( const std::string &  str)

Constructs an instance that represents a value whose string representation is specified as an instance of std::string class.

◆ Decimal() [14/17]

System::Decimal::Decimal ( const String str)

Constructs an instance that represents a value whose string representation is specified as an instance of String class.

◆ Decimal() [15/17]

System::Decimal::Decimal ( int32_t  lo,
int32_t  mid,
int32_t  hi,
bool  isNegative,
uint8_t  scale 
)

Constructs a Decimal object from the specified from the specified components.

Parameters
loThe low 32 bits of the value
midThe middel 32 bits of the value
hiThe high 32 bits of the value
isNegativeSpecifies if the value is negative
scaleA power of 10 ranging from 0 to 28

◆ Decimal() [16/17]

System::Decimal::Decimal ( const Decimal d)

Constructs an instance of Decimal class that represents the same number as the specified Decimal object.

Parameters
dA Decimal object to copy the value from

◆ ~Decimal()

System::Decimal::~Decimal ( )

Destructor.

◆ Decimal() [17/17]

System::Decimal::Decimal ( const number_type value)

Constructs an instance of Decimal class representing the specified value.

Parameters
valueA constant reference to the value to be represented by the object being constructed

Member Function Documentation

◆ Ceiling()

static Decimal System::Decimal::Ceiling ( Decimal  d)
static

Returns the smallest integral value that is greater than or equal to the specified value.

Parameters
dA decimal number
Returns
The smallest integral value that is greater than or equal to d

◆ Compare()

static int System::Decimal::Compare ( Decimal  d1,
Decimal  d2 
)
inlinestatic

Determines if the value represented by the first Decimal object is less than, equal to or greater than the value represented by the second Decimal object.

Parameters
d1The first comparand
d2The second comparand
Returns
-1 if the value represented by d1 is less than the value represented by d2; 0 if the values are equal; 1 if the value represented by d1 is greater than the value represented by d2

◆ CompareTo()

int System::Decimal::CompareTo ( const Decimal d) const

Determines if the value represented by the current object is less than, equal to or greater than the value represented by the specified object.

Parameters
dThe comparand
Returns
-1 if the value represented by the current object is less than the value represented by d; 0 if the values are equal; 1 if the value represented by the current object is greater than the value represented by d

◆ Equals() [1/2]

bool System::Decimal::Equals ( const Decimal d) const

Determines if the values represented by the current object and the specified object are equal.

Parameters
dThe Decimal object to compare the current object with
Returns
True if the value represented by the current and the specified objects are equal, otherwise - false

◆ Equals() [2/2]

static bool System::Decimal::Equals ( Decimal  d1,
Decimal  d2 
)
inlinestatic

Determines if the values represented by the specified objects are equal.

Parameters
d1The first comparand
d2The second comparand
Returns
True if the values represented by d1 and d2 are equal, otherwise - false

◆ Floor()

static Decimal System::Decimal::Floor ( Decimal  d)
static

Returns the largest integral value that is less than or equal to the specified value.

Parameters
dA decimal number
Returns
The largest integral value that is less than or equal to d

◆ GetBits()

static System::ArrayPtr<int> System::Decimal::GetBits ( Decimal  d)
static

Converts the specified Decimal object into the binary representation of the value it represents.

Parameters
dThe Decimal object to convert
Returns
An array whos elements represent distinct bits of the binary representation of the value represented by d

◆ GetBytes()

static void System::Decimal::GetBytes ( Decimal  value,
const System::ArrayPtr< uint8_t > &  buffer 
)
static

Convert the specified Decimal value to an array of bytes.

Parameters
valueThe Decimal value to convert
bufferThe output parameter that, if the conversion succeeds, contains the result of conversion when the method returns.

◆ GetHashCode()

int System::Decimal::GetHashCode ( ) const

Returns a hash code for the current object.

◆ operator bool()

System::Decimal::operator bool ( ) const
explicit

Converts the value represented by the current object to a boolean value.

Returns
True if the value represented by the current object is not 0, otherwise - false

◆ operator double()

System::Decimal::operator double ( ) const
explicit

Converts the value represented by the current object to double-precision floating-point value.

◆ operator float()

System::Decimal::operator float ( ) const
explicit

Converts the value represented by the current object to single-precision floating-point value.

◆ operator!=() [1/2]

bool System::Decimal::operator!= ( const Decimal d) const

Determines if the values represented by the current object and the specified object are not equal.

Parameters
dThe Decimal object to compare the current object with
Returns
True if the value represented by the current and the specified objects are not equal, otherwise - false

◆ operator!=() [2/2]

bool System::Decimal::operator!= ( std::nullptr_t  ) const

Determines if the value represented by the current object is different from 0.

Returns
True if the value represented by the current object is different from 0, otherwise - false

◆ operator%()

Decimal System::Decimal::operator% ( const Decimal d) const

Returns a new instance of Decimal class that represents a value that is a result of modulo operation with the values represented by the curent and the specified objects.

Parameters
dThe Decimal object representing the divisor
Returns
A new instance of Decimal class that represents a value that is a result of modulo operation with the values represented by the curent and the specified objects.

◆ operator%=()

Decimal& System::Decimal::operator%= ( const Decimal d)

Assigns to the current object a new value that is the result of modulo operation with the values represented by the curent and the specified objects.

Parameters
dThe Decimal object representing the divisor
Returns
A reference to the self

◆ operator*()

Decimal System::Decimal::operator* ( const Decimal d) const

Returns a new instance of Decimal class that represents a value that is a result of multiplication of values represented by the current and specified objects.

Parameters
dThe Decimal object representing the multiplier
Returns
A new instance of Decimal class that represents a value that is a result of multiplication of values represented by the current and specified objects

◆ operator*=()

Decimal& System::Decimal::operator*= ( const Decimal d)

Assigns to the current object a new value that is the result of multiplication of values represented by the current and specified objects.

Parameters
dThe Decimal object representing the multiplier
Returns
A reference to the self

◆ operator+()

Decimal System::Decimal::operator+ ( const Decimal d) const

Returns a new instance of Decimal class that represents a value that is a sum of values represented by the current and specified objects.

Parameters
dThe Decimal object representing the value to add
Returns
A new instance of Decimal class that represents a value that is a sum of values represented by the current and specified objects

◆ operator++()

Decimal& System::Decimal::operator++ ( )

Increments the value represented by the current object.

Returns
The reference to the self

◆ operator+=()

Decimal& System::Decimal::operator+= ( const Decimal d)

Assigns to the current object a new value that is a sum of values represented by the current and specified objects.

Parameters
dThe Decimal object representing the value to add
Returns
A reference to the self

◆ operator-() [1/2]

Decimal System::Decimal::operator- ( const Decimal d) const

Returns a new instance of Decimal class that represents a value that is the result of subtraction of the value represented by the specified object from the value represented by the current object.

Parameters
dThe Decimal object representing the value to subtract
Returns
A new instance of Decimal class that represents a value that is the result of subtraction of the value represented by the specified object from the value represented by the current object

◆ operator-() [2/2]

Decimal System::Decimal::operator- ( ) const

Returns a new instance of Decimal class that represents a value that results from negation of the value represented by the current object.

◆ operator--()

Decimal& System::Decimal::operator-- ( )

Decrements the value represented by the current object.

Returns
The reference to the self

◆ operator-=()

Decimal& System::Decimal::operator-= ( const Decimal d)

Assigns to the current object a new value that is the result of subtraction of the value represented by the specified object from the value represented by the current object.

Parameters
dThe Decimal object representing the value to subtract
Returns
A reference to the self

◆ operator/()

Decimal System::Decimal::operator/ ( const Decimal d) const

Returns a new instance of Decimal class that represents a value that is a result of division of the value represented by the current object by the value represented by the specified object.

Parameters
dThe Decimal object representing the divisor
Returns
A new instance of Decimal class that represents a value that is a result of division of the value represented by the current object by the value represented by the specified object.

◆ operator/=()

Decimal& System::Decimal::operator/= ( const Decimal d)

Assigns to the current object a new value that is the result of division of the value represented by the current object by the value represented by the specified object.

Parameters
dThe Decimal object representing the divisor
Returns
A reference to the self

◆ operator<()

bool System::Decimal::operator< ( const Decimal d) const

Determines if the value represented by the current object is less than the value represented by the specified object.

Parameters
dThe Decimal object to compare the current object with
Returns
True if the value represented by the current object is less than the value represented by d, otherwise - false

◆ operator<=()

bool System::Decimal::operator<= ( const Decimal d) const

Determines if the value represented by the current object is less than or equal to the value represented by the specified object.

Parameters
dThe Decimal object to compare the current object with
Returns
True if the value represented by the current object is less than or equal to the value represented by d, otherwise - false

◆ operator=()

Decimal& System::Decimal::operator= ( const Decimal d)

Assigns the value represented by the specified object to the current object.

Parameters
dDecimal object to copy the value from
Returns
The reference to the self

◆ operator==() [1/2]

bool System::Decimal::operator== ( const Decimal d) const

Determines if the values represented by the current object and the specified object are equal.

Parameters
dThe Decimal object to compare the current object with
Returns
True if the value represented by the current and the specified objects are equal, otherwise - false

◆ operator==() [2/2]

bool System::Decimal::operator== ( std::nullptr_t  ) const

Determines if the value represented by the current object is 0.

Returns
True if the value represented by the current object is 0, otherwise - false

◆ operator>()

bool System::Decimal::operator> ( const Decimal d) const

Determines if the value represented by the current object is greater than the value represented by the specified object.

Parameters
dThe Decimal object to compare the current object with
Returns
True if the value represented by the current object is greater than the value represented by d, otherwise - false

◆ operator>=()

bool System::Decimal::operator>= ( const Decimal d) const

Determines if the value represented by the current object is greater than or equal to the value represented by the specified object.

Parameters
dThe Decimal object to compare the current object with
Returns
True if the value represented by the current object is greater than or equal to the value represented by d, otherwise - false

◆ Parse() [1/2]

static Decimal System::Decimal::Parse ( const String str)
inlinestatic

Converts the string representation of a decimal number into an equivalent instance of Decimal class.

Parameters
strThe string representation of a number
Returns
A new instance of Decimal class repsenting a value equivalent to that represented by the specified string.

◆ Parse() [2/2]

static Decimal System::Decimal::Parse ( const String s,
System::Globalization::NumberStyles  style 
)
static

Converts the string representation of a decimal number into an equivalent instance of Decimal class using the specified style.

Parameters
sThe string representation of a decimal value to convert
styleA bitwise combination of the enumeration values that provides additional information about s, about style elements that may be present in s, or about the conversion from s to a Decimal object
Returns
A new instance of Decimal class repsenting a value equivalent to that represented by the specified string

◆ Round() [1/2]

static Decimal System::Decimal::Round ( Decimal  d,
MidpointRounding  mode = MidpointRounding::ToEven 
)
static

Rounds the specified value to the nearest integral number. A parameter specifies the function's behavior if the specified value is equally close to two nearest numbers.

Parameters
dThe value to round
modeSpecifies how to perform the rounding if value is equally close to two nearest numbers.
Returns
d rounded to the nearest integral value

◆ Round() [2/2]

static Decimal System::Decimal::Round ( Decimal  d,
int  digits,
MidpointRounding  mode = MidpointRounding::ToEven 
)
static

Rounds the specified value to the nearest value with the specified number of fractional digits. A parameter specifies the function's behavior if the specified value is equally close to two nearest numbers.

Parameters
dThe value to round
digitsThe number of fractional digits in the rounded value
modeSpecifies how to perform the rounding if value is equally close to two nearest numbers.
Returns
The number with the specified number of digits nearest to value

◆ ToStdString()

std::string System::Decimal::ToStdString ( ) const

Returns an instance of std::string that contains the string representation of the value represented by the object.

◆ ToString()

String System::Decimal::ToString ( ) const

Returns the string representation of the value represented by the object.

◆ Truncate()

static Decimal System::Decimal::Truncate ( Decimal  d)
static

Returns the Decimal object representing a value that has integral part equal to that of the value represented by the specified Decimal object of the with all fractional digits discarded.

Parameters
dA decimal number
Returns
A Decimal object reprsenting a decimal value whose integral part is equal to that of the specified value and fractional digits are all 0.

◆ Type()

static const TypeInfo& System::Decimal::Type ( )
inlinestatic

Returns a reference to the TypeInfo object representing the Decimal class' type information.

Member Data Documentation

◆ MaxValue

const Decimal ASPOSECPP_SHARED_API System::Decimal::MaxValue
static

Represents the largest number that can be represented by Decimal class.

◆ MinusOne

const Decimal ASPOSECPP_SHARED_API System::Decimal::MinusOne
static

Represents number -1.

◆ MinValue

const Decimal ASPOSECPP_SHARED_API System::Decimal::MinValue
static

Represents the smallest number that can be represented by Decimal class.

◆ One

const Decimal ASPOSECPP_SHARED_API System::Decimal::One
static

Represets number 1.

◆ Zero

const Decimal ASPOSECPP_SHARED_API System::Decimal::Zero
static

Represents number 0.