System::Decimal class

Decimal class

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.

class Decimal

Methods

MethodDescription
static Add(const Decimal&, const Decimal&)Adds two specified Decimal values.
static Ceiling(const Decimal&)Returns the smallest integral value that is greater than or equal to the specified value.
static Compare(const Decimal&, const Decimal&)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.
CompareTo(const Decimal&) constDetermines if the value represented by the current object is less than, equal to or greater than the value represented by the specified object.
Decimal()Constructs an instance that represents 0.
Decimal(std::int8_t)Constructs an instance that represents the specified value.
Decimal(std::int16_t)Constructs an instance that represents the specified value.
Decimal(std::int32_t)Constructs an instance that represents the specified value.
Decimal(std::int64_t)Constructs an instance that represents the specified value.
Decimal(std::uint8_t)Constructs an instance that represents the specified value.
Decimal(std::uint16_t)Constructs an instance that represents the specified value.
Decimal(std::uint32_t)Constructs an instance that represents the specified value.
Decimal(std::uint64_t)Constructs an instance that represents the specified value.
Decimal(float)Constructs an instance that represents the specified value.
Decimal(double)Constructs an instance that represents the specified value.
explicit Decimal(const std::string&)Constructs an instance that represents a value whose string representation is specified as an instance of std::string class.
Decimal(int32_t, int32_t, int32_t, bool, uint8_t)Constructs a Decimal object from the specified from the specified components.
Decimal(const Decimal&)Constructs an instance of Decimal class that represents the same number as the specified Decimal object.
Decimal(const ArrayPtr<int32_t>&)Constructs an instance of Decimal class from integer array containing a binary representation.
Decimal(std::nullptr_t)Always throws ArgumentNullException.
Decimal(const number_type&)Constructs an instance of Decimal class representing the specified value.
static Divide(const Decimal&, const Decimal&)Divides two specified Decimal values.
Equals(const Decimal&) constDetermines if the values represented by the current object and the specified object are equal.
Equals(const SharedPtr<Object>&) constDetermines if the values represented by the current object and the specified object are equal.
static Equals(const Decimal&, const Decimal&)Determines if the values represented by the specified objects are equal.
static Floor(const Decimal&)Returns the largest integral value that is less than or equal to the specified value.
static FromOACurrency(int64_t)Convert the specified OLE currency value to the equivalent Decimal value. NOT IMPLEMENTED.
static GetBits(const Decimal&)Converts the specified Decimal object into the binary representation of the value it represents.
static GetBytes(const Decimal&, const System::ArrayPtr<uint8_t>&)Convert the specified Decimal value to an array of bytes.
GetHashCode() constReturns a hash code for the current object.
GetTypeCode() constGets object type code.
static Multiply(const Decimal&, const Decimal&)Multiplies two specified Decimal values.
static Negate(const Decimal&)Returns a new instance of Decimal class that represents a value that results from negation of the value represented by the specified object.
explicit operator bool() constConverts the value represented by the current object to a boolean value.
explicit operator double() constConverts the value represented by the current object to double-precision floating-point value.
explicit operator float() constConverts the value represented by the current object to single-precision floating-point value.
operator!=(const Decimal&) constDetermines if the values represented by the current object and the specified object are not equal.
operator!=(std::nullptr_t) constDetermines if the value represented by the current object is different from 0.
operator%(const Decimal&) constReturns a new instance of Decimal class that represents a value that is a result of modulo operation with the values represented by the current and the specified objects.
operator%=(const Decimal&)Assigns to the current object a new value that is the result of modulo operation with the values represented by the current and the specified objects.
operator*(const Decimal&) constReturns 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*=(const Decimal&)Assigns to the current object a new value that is the result of multiplication of values represented by the current and specified objects.
operator+(const Decimal&) constReturns a new instance of Decimal class that represents a value that is a sum of values represented by the current and specified objects.
operator++()Increments the value represented by the current object.
operator+=(const Decimal&)Assigns to the current object a new value that is a sum of values represented by the current and specified objects.
operator-(const Decimal&) constReturns 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-() constReturns a new instance of Decimal class that represents a value that results from negation of the value represented by the current object.
operator–()Decrements the value represented by the current object.
operator-=(const Decimal&)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.
operator/(const Decimal&) constReturns 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/=(const Decimal&)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.
operator<(const Decimal&) constDetermines if the value represented by the current object is less than the value represented by the specified object.
operator<=(const Decimal&) constDetermines if the value represented by the current object is less than or equal to the value represented by the specified object.
operator=(const Decimal&)Assigns the value represented by the specified object to the current object.
operator==(const Decimal&) constDetermines if the values represented by the current object and the specified object are equal.
operator==(std::nullptr_t) constDetermines if the value represented by the current object is 0.
operator>(const Decimal&) constDetermines if the value represented by the current object is greater than the value represented by the specified object.
operator>=(const Decimal&) constDetermines if the value represented by the current object is greater than or equal to the value represented by the specified object.
static Parse(const String&)Converts the string representation of a decimal number into an equivalent instance of Decimal class.
static Parse(const String&, Globalization::NumberStyles)Converts the string representation of a decimal number into an equivalent instance of Decimal class using the specified style.
static Parse(const String&, const SharedPtr<IFormatProvider>&)Converts the string representation of a decimal number into an equivalent instance of Decimal class using the specified format provider.
static Parse(const String&, Globalization::NumberStyles, const SharedPtr<IFormatProvider>&)Converts the string representation of a decimal number into an equivalent instance of Decimal class using the specified style and format provider.
static Remainder(const Decimal&, const Decimal&)Computes the remainder after dividing two Decimal values.
static Round(const Decimal&, MidpointRounding)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.
static Round(const Decimal&, int, MidpointRounding)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.
static Subtract(const Decimal&, const Decimal&)Subtracts one specified Decimal value from another.
static ToByte(Decimal)Converts the Decimal value to unsigned 8-bit integer value.
static ToDouble(Decimal)Converts the Decimal value to double precision floating-point number.
static ToInt16(Decimal)Converts the Decimal value to signed 16-bit integer value.
static ToInt32(Decimal)Converts the Decimal value to signed 32-bit integer value.
static ToInt64(Decimal)Converts the Decimal value to signed 64-bit integer value.
static ToOACurrency(const Decimal&)Convert the specified Decimal value to the equivalent OLE currency value. NOT IMPLEMENTED.
static ToSByte(Decimal)Converts the Decimal value to signed 8-bit integer value.
static ToSingle(Decimal)Converts the Decimal value to single precision floating-point number.
ToStdString() constReturns an instance of std::string that contains the string representation of the value represented by the object.
ToString() constReturns the string representation of the value represented by the object.
ToString(const SharedPtr<IFormatProvider>&) constConverts current object to string using the culture-specific format information.
ToString(const SharedPtr<Globalization::CultureInfo>&) const
ToString(const SharedPtr<Globalization::NumberFormatInfo>&) const
ToString(const Decimal&, std::nullptr_t) const
ToString(const String&, const SharedPtr<IFormatProvider>&) constConverts current object to its string representation using the specified string format and culture-specific format information provided by the specified IFormatProvider object.
ToString(const String&, const SharedPtr<Globalization::CultureInfo>&) const
ToString(const String&, const SharedPtr<Globalization::NumberFormatInfo>&) const
ToString(const String&, std::nullptr_t) const
ToStringInternal() constReturns the string representation of the value represented by the object. For internal use.
static ToUInt16(Decimal)Converts the Decimal value to unsigned 16-bit integer value.
static ToUInt32(Decimal)Converts the Decimal value to unsigned 32-bit integer value.
static ToUInt64(Decimal)Converts the Decimal value to unsigned 64-bit integer value.
static Truncate(const Decimal&)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.
static TryParse(const String&, Decimal&)Converts the specified string containing the string representation of a number to the equivalent Decimal value.
static TryParse(const String&, Globalization::NumberStyles, const SharedPtr<IFormatProvider>&, Decimal&)Converts the specified string containing the string representation of a number to the equivalent Decimal value using the provided formatting information and number style.
static Type()Returns a reference to the TypeInfo object representing the Decimal class’ type information.
~Decimal()Destructor.

Fields

FieldDescription
static MaxValueRepresents the largest number that can be represented by Decimal class.
static MinusOneRepresents number -1.
static MinValueRepresents the smallest number that can be represented by Decimal class.
static OneRepresents number 1.
static ZeroRepresents number 0.

Typedefs

TypedefDescription
number_typeAn alias for Detail::decimal_number_type.

Remarks

#include "system/console.h"
#include "system/decimal.h"

int main()
{
  using namespace System;

  Console::WriteLine(Decimal::MinValue);
  Console::WriteLine(Decimal::MaxValue);

  auto dividend = Decimal::One;
  auto divisor = 6;
  Console::WriteLine(dividend/divisor);

  return 0;
}
/*
This code example produces the following output:
-79228162514264337593543950335
79228162514264337593543950335
0,1666666666666666666666666667
*/

See Also