Try OpenEdge Now
skip to main content
GUI for .NET Programming
Using .NET data types in ABL : Implicit data type mappings : ABL DECIMAL and .NET System.Decimal
 

ABL DECIMAL and .NET System.Decimal

The following example raises a run-time error because a large ABL DECIMAL is passed to a .NET System.Decimal method parameter:
DEFINE VARIABLE dResult AS DECIMAL NO-UNDO.

dResult = System.Math:Abs
  (-22123456789012345678901234584575656.67). /* Run-time error */
A .NET System.Decimal can hold a positive or negative value with a maximum of 29 digits (79,228,162,514,264,337,593,543,950,335), and the specified ABL DECIMAL value passed to the System.Decimal parameter has 37 digits, including 2 digits to the right of the decimal point.
The following example truncates the least significant digits of the result from dividing one .NET System.Decimal value by another and storing it in the ABL DECIMAL variable, dResult:
DEFINE VARIABLE dResult AS DECIMAL NO-UNDO.

dResult = System.Decimal:MaxValue / System.Math:Pow(10, 28).
In this case, the maximum System.Decimal value is divided by 1028. In a CLS-compliant language, the result of this calculation is a System.Decimal with the value of 7.9228162514264337593543950335. However, an ABL DECIMAL cannot represent a value with more than 10 digits to the right of the decimal point. So, the value of the dResult variable is 7.9228162514, truncating the least significant 18 digits.