NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Decimal Structure

Represents a decimal value.

Object
   ValueType
      Decimal

[Visual Basic]
Public Structure Decimal
   Implements IFormattable, IComparable, IConvertible
[C#]
public struct Decimal : IFormattable, IComparable, IConvertible
[C++]
public __value struct Decimal : public IFormattable, IComparable,
   IConvertible

[JScript] In JScript, you can use the structures in the NGWS frameworks, but you cannot define your own.

Remarks

The Decimal data type can represent positive and negative values with 28 significant digits, ranging from positive 79,228,162,514,264,337,593,543,950,335 through negative 79,228,162,514,264,337,593,543,950,335.

The Decimal type is well suited to financial calculations that require a large number of significant digits and no round-off errors. (For additional information about specific number formatting and cultures, see Globalization Namespace, NumberFormatInfo and CultureInfo.)

The finite set of values of type Decimal are of the form m/ 10 e, where m is an integer such that-296 < m < 296, and e is an integer between 0 and 28 inclusive.

In contrast to the Single (float) and Double data types, decimal fractional numbers, such as 0.1, can be represented exactly in the decimal representation. In the Single and Double representations, such numbers are often infinite fractions, making those representations more prone to round-off errors.

The Decimal class implements widening conversions from the Byte, Char, Int16, Int32, and Int64 types to Decimal. These widening conversions never lose any information and never throw exceptions.

The Decimal class also implements narrowing conversions from Decimal to Byte, Char, Int16, Int32, and Int64. These narrowing conversions round the Decimal value toward zero to the nearest integer, and then convert that integer to the destination type. An OverflowException is thrown if the result is not within the range of the destination type.

The Decimal class also provides a widening conversion from Currency to a Decimal. This widening conversion never looses any information and never throws exceptions. The Currency class provides a narrowing conversion from Decimal to Currency. This narrowing conversion rounds the Decimal to four decimals and then converts that number to a Currency. An OverflowException is thrown if the result is not within the range of the Currency type.

The Decimal class provides narrowing conversions to and from the Single and Double types. A conversion from Decimal to Single or Double may lose precision, but will not lose information about the overall magnitude of the numeric value. It will never throw an exception. A conversion from a Single or a Double to a Decimal throws an OverflowException if the value is not within the range of the Decimal type.

Requirements

Namespace: System

Assembly: mscorlib.dll

See Also

Decimal Members | System Namespace