Decimal

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