Skip to main content

Problem:

Arithmetic statements produce different results when run in int form and other program forms(.gnt,.so, or executable)

Resolution:

In some cases different results for arithmetic statements are produced when running programs compiled to int executable form versus running the same program compiled to .gnt (or other object code) form.

There are a number of different causes for this problem/symptom. One possible cause is that the arithmentic operation is constructed in a way that allows the result prodcuced to be larger than the the capacity of the data item where the result is to be stored. INT code hides these kinds of things, while object code forms do not.

To determine if a particular arithmentic operation is failing because of this unintended overflow condition, modify the statement to include the ON SIZE Error clause.

examples:

Original suspect statment

COMPUTE C = A * B

Test for Size Error

COMPUTE C = A * B ON SIZE ERROR STOP "SIZE ERROR"

If test results show that a size error is occuring then the code should be modified to correct for  this circumstance. - If there is no size error detected, then there is another unreleated cause for the apparent error in the calculation.

NOTES - The differences in results may disappear when the ON SIZE ERROR clause is added - The important thing to identify is - Is incorrect result produced because a SIZE ERROR is occuring.

Using ON SIZE error can affect program performance, better performance can be acheived by ensuring that the data items receiving arithmetic results a large enough to contain the largest possible result for the computation in question.

Old KB# 2268