Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cobol help calculate a remainder

Status
Not open for further replies.

AFPBoy

Programmer
Apr 26, 2002
5
US
How can you calculate a remainder in Cobol

ex.

1197/103 = 11 remainder 67

 
The easy way:
DIVIDE <1> BY <2> GIVING <3> REMAINDER <4>.
<1> and <2> are numeric fields or literals
<3> and <4> are numeric fields

The other easy way: :)
COMPUTE <4> = <1> - (( <1> / <2> ) * <2> )


Marcel
 
After I send my post, I found the real reason for your question: The remainder of 1197 divided by 103 is 64 and not 67 :-(

Good you asked this forum. Marcel
 
Also, depending upon your compiler you can
COMPUTE WS-REMAINDER = FUNCTION MOD ( 1197, 103)
but Marcel is right, the remainder is 64!
Marc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top