The Decimal Data TypeDecimal 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.
double dValue = 1.333f;
string strDouble = dValue.ToString( "f4" );//strDouble is "1.3330"
string strDouble = dValue.ToString( "0.00" );//strDouble is "1.33"
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.