|
|
System.Decimal Structure |
|
|
Description | |
|
The Decimal structure is explicitly designed to hold very large numbers with a large number of significant digits, as required by financial applications - no errors can be created by rounding.
Internally, the number is held in 3 parts :
Sign | + or - |
Mantissa | A 96 bit number, holding the significant digits |
Exponent | 0 to 28 decimal places |
The range of numbers supported is given in the MinValue and MaxValue fields below.
The Array of Int32 constructor provides the decimal value in 4 Int32 values :
Array[0] | Low order 32 bits of the 96 bit mantissa |
Array[1] | Mid order 32 bits of the 96 bit mantissa |
Array[2] | High order 32 bits of the 96 bit mantissa |
Array[3] | Bits 16-23 contain the exponent, bit 31 the sign |
Likewise, the final constructor allows a piecemeal build of the decimal value.
|
|
Syntax | |
|
Constructor Create ( | Value : Int16 ); | Constructor Create ( |
Value : Int32 ); | Constructor Create ( |
Value : UInt16 ); | Constructor Create ( |
Value : UInt32 ); | Constructor Create ( |
Value : Single ); | Constructor Create ( |
Value : Double ); | Constructor Create ( |
Values : Array of Int32 ); | Constructor Create ( |
Low : Int32; Mid : Int32; High : Int32; IsNegative : Boolean; Exponent : Byte ); |
|
Methods | |
|
| Add | Adds two Decimal values together |
| Compare | Compares one Decimal value with another |
| CompareTo | Compares the current Decimal value to another |
| Divide | Divides one Decimal value by another |
| Equals | Determines if the current Decimal equals another |
| Floor | Finds the lowest relative integer value nearest to the specified decimal |
| GetBits | Converts a Decimal number value into an array of Integers |
| Multiply | Multiplies one Decimal value by another |
| Negate | Returns the supplied decimal value negated |
| Parse | Converts a string representation of a Decimal into a Decimal value |
| Remainder | Divides one Decimal value by another and returns the remainder |
| Round | Rounds a Decimal number to the nearest value using Bankers rules |
| Subtract | Subtracts one Decimal value from another |
| Truncate | Drops the fractional part of a decimal number |
|
|
|
Fields | |
|
MinValue | | Decimal | | -79,228,162,514,264,337,593,543,950,335 |
MaxValue | | Decimal | | 79,228,162,514,264,337,593,543,950,335 |
Zero | | Decimal | | 0 |
MinusOne | | Decimal | | -1 |
One | | Decimal | | 1 |
|
Operators | |
|
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
% | Modulus - the remainder from a divide |
< | Less than |
<= | Less than or equal |
= | Equality |
>= | Greater than or equal |
> | Greater than |
|
Microsoft MSDN links | |
|
|
|
|
|
|