Public Types

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

Public Member Functions

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

Static Public Member Functions

static ASPOSECPP_SHARED_API Decimal Round (Decimal d, MidpointRounding mode=MidpointRounding::ToEven)
 
static ASPOSECPP_SHARED_API Decimal Round (Decimal d, int digits, MidpointRounding mode=MidpointRounding::ToEven)
 
static ASPOSECPP_SHARED_API Decimal Truncate (Decimal d)
 
static ASPOSECPP_SHARED_API Decimal Ceiling (Decimal d)
 
static ASPOSECPP_SHARED_API 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 ASPOSECPP_SHARED_API 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 ASPOSECPP_SHARED_API System::ArrayPtr< int > GetBits (Decimal d)
 
static ASPOSECPP_SHARED_API 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/18]

ASPOSECPP_SHARED_API System::Decimal::Decimal ( )

Constructs an intsance that represents 0.

◆ Decimal() [2/18]

ASPOSECPP_SHARED_API 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/18]

ASPOSECPP_SHARED_API 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/18]

ASPOSECPP_SHARED_API 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/18]

ASPOSECPP_SHARED_API 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/18]

ASPOSECPP_SHARED_API 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/18]

ASPOSECPP_SHARED_API 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/18]

ASPOSECPP_SHARED_API 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/18]

ASPOSECPP_SHARED_API 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/18]

ASPOSECPP_SHARED_API 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/18]

ASPOSECPP_SHARED_API 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/18]

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

Constructs an instance that represents 0.

◆ Decimal() [13/18]

ASPOSECPP_SHARED_API 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/18]

ASPOSECPP_SHARED_API 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/18]

ASPOSECPP_SHARED_API 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/18]

ASPOSECPP_SHARED_API 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() [17/18]

ASPOSECPP_SHARED_API System::Decimal::Decimal ( ArrayPtr< int32_t >  bits)

Constructs an instance of Decimal class from integer array containing a binary representation.

Parameters
bitsA integer array containing a binary representation.

◆ ~Decimal()

ASPOSECPP_SHARED_API System::Decimal::~Decimal ( )

Destructor.

◆ Decimal() [18/18]

ASPOSECPP_SHARED_API 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 ASPOSECPP_SHARED_API 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()

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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 ASPOSECPP_SHARED_API 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 ASPOSECPP_SHARED_API 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 ASPOSECPP_SHARED_API 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()

ASPOSECPP_SHARED_API int System::Decimal::GetHashCode ( ) const

Returns a hash code for the current object.

◆ operator bool()

ASPOSECPP_SHARED_API 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()

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

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

◆ operator float()

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

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

◆ operator!=() [1/2]

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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%()

ASPOSECPP_SHARED_API 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%=()

ASPOSECPP_SHARED_API 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*()

ASPOSECPP_SHARED_API 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*=()

ASPOSECPP_SHARED_API 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+()

ASPOSECPP_SHARED_API 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++()

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

Increments the value represented by the current object.

Returns
The reference to the self

◆ operator+=()

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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--()

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

Decrements the value represented by the current object.

Returns
The reference to the self

◆ operator-=()

ASPOSECPP_SHARED_API 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/()

ASPOSECPP_SHARED_API 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/=()

ASPOSECPP_SHARED_API 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<()

ASPOSECPP_SHARED_API 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<=()

ASPOSECPP_SHARED_API 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=()

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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]

ASPOSECPP_SHARED_API 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>()

ASPOSECPP_SHARED_API 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>=()

ASPOSECPP_SHARED_API 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 ASPOSECPP_SHARED_API 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 ASPOSECPP_SHARED_API 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 ASPOSECPP_SHARED_API 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()

ASPOSECPP_SHARED_API 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()

ASPOSECPP_SHARED_API String System::Decimal::ToString ( ) const

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

◆ Truncate()

static ASPOSECPP_SHARED_API 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.