Reverse a Number

Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Re: Reverse a Number

Postby steve-myers » Sat Jan 29, 2011 6:13 pm

In Assembler we could do something like-
         MVC   RESULT,=AL1(2,1,0)
         TR    RESULT,SOURCE
RESULT   DC    CL3' '
SOURCE   DC    C'123'
I think the Cobol experts here could come up with something similar.
Global moderator
Posts: 2106
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 242 times

Re: Reverse a Number

Postby BillyBoyo » Sat Jan 29, 2011 7:47 pm

Agreed, but ecause the questioner did not clarify his parameters for the task, I "guessed between the lines" and made the assumption that the reverse would have to be done without defining additional storage.

I suppose in Assembler I can load the field into a register, and do a few bit shifts.
Global moderator
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to IBM Cobol


  • Related topics
    Last post