Consultor Eletrônico



Kbase P119716: Integer, Maximum Value + 1 Generates Error 13682
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   3/12/2007
Status: Verified

FACT(s) (Environment):

OpenEdge 10.1B

SYMPTOM(s):

INTEGER variable is assigned the maximum value for an integer (2147483647)

DISPLAY statement is executed that displays INTEGER + 1

Result of DISPLAY statement in Progress 9.x is -2147483648

Result of DISPLAY statement in OpenEdge 10.1B1B is 2147483648

Value 2147483648 too large to fit in INTEGER datatype. (13682)

CAUSE:

OpenEdge 10.1B uses 64 bit integers internally for all integers. When the DISPLAY statement is invoked the INTEGER + 1 is evaluated internally as an INT64. This is why the value is not rolled around to a negative number as it is in Progress 9.x.

Prior to OpenEdge 10.1B, when we used to have only 32 bits, we were similarily unable to check for 32 bit overflow. Now that we have 64bits we can start checking for 32bit overflow for the first time in OpenEdge 10.1B.
Overflow for INT64 cannot be checked for because there are only 64 bits to work with. When the value goes beyond +-2^63 it will simply overflow and become negative/positive depending on the amount it overflows.
Checking for 64bit overflow would be too expensive. To do it would require putting everything in 128 bits to do calculations and then to copy it all back, since >64bits are required to do 64bit overflow checking. This would cause all arithmetic in the 4gl to grind to a halt. There are therefore no plans to do anything about this.

FIX:

It is not possible via code to get an integer variable containing the maximum integer value to roll around to a negative number when one is added to it. Instead error 13682 will be generated.