Try OpenEdge Now
skip to main content
ABL Data Types Addenda
INT64 data type : INT64 in arithmetic and comparison operations : Mixed INTEGER and INT64 expressions
 

Mixed INTEGER and INT64 expressions

If arithmetic or comparison expressions contain a mix of INTEGER and INT64 data types, the result is an INT64. Dividing an INT64 with another INT64 produces a DECIMAL result, as does dividing two INTEGERs.
INT64 support applies to all of the ABL built-in methods and functions that take integer-expression parameters. That is, integer-expression parameters can be either INT64 expressions or INTEGER expressions.
Note that you cannot pass an INT64 expression into a class-based method that is expecting an INTEGER. Instead, you can use the INTEGER function to convert the expression to INTEGER, which the method is expecting. In particular, you must convert the sequence functions (NEXT-VALUE, CURRENT-VALUE, DYNAMIC-CURRENT-VALUE, DYNAMIC-NEXT-VALUE) to INTEGER if you want to pass them to a class method expecting INTEGER.
The following code example demonstrates arithmetic operations using a mix of INTEGER and INT64 expressions:
DEF VAR x AS INTEGER.
DEF VAR y AS INTEGER.
DEF VAR z AS INTEGER.
DEF VAR big AS INT64.
/* NOTE: as far as the compiler is concerned, x + y is an INTEGER*/
/* NOTE: all failures are RUNTIME failures, not COMPILER failures*/

x = 2000000000.        /*should succeed, just under 2gig*/
y = 2000000000.        /*should succeed, just under 2gig*/

DISPLAY x + y FORMAT ">>>,>>>,>>>,>>>" .  
/*should succeed if format is big enough*/
z = x + y             /* assignment >2gig to INTEGER should fail*/

INTEGER( x +          /*INTEGER function on >2gig should fail*/
big = x + y.          /*assignment >2gig to INT64 should succeed*/

DISPLAY x + y > 2000000000.                    
                      /*compare >2gig with INTEGER constant should succeed*/

DISPLAY x + y > 3000000000.                  
                      /*compare >2gig with INT64 constant should succeed */

PROCEDURE myproc:
  DEF INPUT PARAMETER mp AS INTEGER.
  DISPLAY mp.
END.

RUN myproc(big).      /*INT64 with >2gig should fail*/
RUN myproc(x + y)     /*INTEGER expression with >2gig should fail*/
big = 3.
RUN myproc(big).      /*INT64 with <2gig should succeed*/

big + x.              /*is compiled as returning INT64*/
x + y.                /*is compiled as returning INTEGER*/

y = NEXT-VALUE(next-cust-num).          /*sequence is compiled with INT64
datatype if the sequence is up to >2gig, this will fail*/

big = NEXT-VALUE(next-cust-num).       /*sequence is compiled with INT64
datatype if the sequence is up to >2gig, this will still succeed*/