ABL provides three numeric data types that you can use in your application.

ABL data type Description
INTEGER or INT A 32-bit integer value within the range -2147483648 to +2147483647.
INT64 A 64-bit integer value within the range -9223372036854775808 to +9223372036854775807.
DECIMAL A signed value that holds a maximum of 50 digits, including 10 digits to the right of the decimal place.

All numeric data types have a default initial value of 0. However, you can optionally set initial values when defining variables.

Arithmetic operators

The standard arithmetic operators (+, -, *, /, modulo) are used to perform calculations in ABL. You can perform calculations using variables, constants, database field values, and functions.

Arithmetic operator Name Example
+ + Addition operator dBalance = dBalance + dVarPrice
- - Subtraction operator dBalance = dBalance – dTotalPaid
* * Multiplication operator dExtendedPrice = dPrice * dQuantity
/ / Division operator dVarPrice = dExtendedPrice / iQuantity
modulo MODULO operator dQuota = iTotal MODULO 4

Order of evaluation

The evaluation of numeric expressions in ABL follow the standard order of evaluation used in most programming languages. See the ABL operator precedence table in Develop ABL Applications for details.

Use parentheses for clarity

It is a best practice to use parentheses to explicitly indicate the desired evaluation order. This makes your code clear and easy to maintain, and ensures the result is what you intended.

dBonus =  ((dQuota / dTSales) * dBasePay) + 1000.

In numeric expressions, you can use the + and - operators in two ways. If there is a space between the operator and the following numeric value, then the operator is interpreted as an arithmetic operator. Otherwise, it is interpreted as a unary operator that makes the numeric value a positive or negative value. Make sure you include the space if you want an arithmetic operation.

Comparison operators

ABL provides operators to compare variables. You can use either the character representation or the symbol for each operator.

Operator
EQ or = operator
NE or <> operator
LT or < operator
LE or < = operator
GT or > operator
GE or >= operator

Convert numeric data

You should be mindful of how numeric data may be automatically converted. If you add an INTEGER with a DECIMAL then the result is converted to the DECIMAL type. If you assign a DECIMAL value to an INTEGER variable, then the result is converted to an INTEGER with rounding.

In addition, ABL provides built-in functions to convert and operate on numeric data, as shown. Note that these functions require parameters.

ABL function
ABSOLUTE
DECIMAL
EXP
INTEGER
INT64
LOG
MAXIMUM
MINIMUM
RANDOM
ROUND
SQRT
TRUNCATE

Example using INTEGER, ROUND, and TRUNCATE

The following example code demonstrates the INTEGER, ROUND, and TRUNCATE functions:

VAR DECIMAL test = 350.9875.

MESSAGE "Original value:" test SKIP
  "Integer value:" INTEGER(test) SKIP
  "Rounded value:" ROUND(test,0) SKIP
  "Truncated value:" TRUNCATE(test,0).

The example code produces the following output:

Original value: 350.9875 
Integer value: 351 
Rounded value: 351 
Truncated value: 350