gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[open-cobol-list] Divide and Remainder - '85 vs '02 Standards


From: Bill Klein
Subject: [open-cobol-list] Divide and Remainder - '85 vs '02 Standards
Date: Wed Mar 8 13:32:19 2006

There was a VERY odd rule in the '85 Standard that some (but not many)
implementors actually followed.  It had to do with cases where one operand
had a sign defined an another did not. 

The '02 Standard has the following on page 816

"17) Calculation of remainder in DIVIDE statement. When a remainder is
calculated, the value is independent of whether the receiving operand for
the quotient is signed or unsigned.

Justification:
In the previous COBOL standard, the value obtained for the remainder when
the dividend and divisor have different signs differs depending on whether
the receiving operand for the quotient is signed or unsigned. This is
considered a mathematically incorrect result. The new rules yield the same
value for the remainder regardless of the presence or absence of a sign in
the receiving operand for the quotient.

It is believed that the benefits of portability outweigh the
upward-compatibility problem. The implementor is required to provide a
compiler diagnostic when the ALL or DIVIDE phrase of the FLAG-85 directive
is specified."

I do NOT think this is relevant to the current work on DIVIDE ... REMAINDER
... but I thought you should be aware of this - especially as some
implementations did one thing and some the other (for the '85 Standard)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]