Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Decimal Data Type

Decimal variables are stored as signed 128-bit (16-byte) integers scaled by a variable power of 10. The scaling factor specifies the number of digits to the right of the decimal point; it ranges from 0 through 28. With a scale of 0 (no decimal places), the largest possible value is +/-79,228,162,514,264,337,593,543,950,335. With 28 decimal places, the largest value is +/-7.9228162514264337593543950335, and the smallest nonzero value is +/-0.0000000000000000000000000001 (+/-1E-28).

Appending the literal type character D to a literal forces it to the Decimal data type. Appending the identifier type character @ to any identifier forces it to Decimal. You might need to use the D type character to assign a large value to a Decimal variable or constant, as the following example shows:

Dim BigDec1 As Decimal = 9223372036854775807   ' No overflow.
Dim BigDec2 As Decimal = 9223372036854775808   ' Overflow.
Dim BigDec3 As Decimal = 9223372036854775808D  ' No overflow.

This is because without a literal type character the literal is taken as Long, and the value to be assigned to BigDec2 is too large for the Long type.

The equivalent .NET data type is System.Decimal.

See Also

Data Type Summary | Decimal Structure | Type Conversion Functions | Conversion Summary | Efficient Use of Data Types

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft