Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
saagu

New User

Joined: 15 May 2008
Posts: 41
Location: Chennai

 Posted: Fri Apr 10, 2009 3:42 pm    Post subject: maximum value in S9(09) COMP Hi, What is the maximum value that can be fit in "ws-var1 S9(09) COMP". Value 2145555555 (10 digits) is also able to fit in above variable. Is maximum value for s9(9) is not '999999999'??? Plz let me know on this. Regards, Saagu

dbzTHEdinosauer

Global Moderator

Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

 Posted: Fri Apr 10, 2009 3:59 pm    Post subject: Saagu, one of the things you will have to learn is how to look-up such questions in the documentation. to start with, COBOL (why post this in the JCL forum?) does not really matter what release of cobol, data definitions have been rather consistent. top of the page, manuals button. might as well read about numerics in general as well as binary and you will learn why s9(9) COMP is not 999999999.
Gnanas N

Active Member

Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

 Posted: Fri Apr 10, 2009 4:01 pm    Post subject: +2147483647
Bill O'Boyle

CICS Moderator

Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

 Posted: Fri Apr 10, 2009 4:07 pm    Post subject: Reply to: maximum value in S9(09) COMP Depending on the compile option TRUNC, the maximum 'signed' value is 2147483647, because this is represented internally as a binary fullword (X'7FFFFFFF'). An unsigned maximum value would be 4294967295 (X'FFFFFFFF'). IIRC, TRUNC(OPT) limits the maximum (in your example) to 999999999, because truncation is based upon the picture clause. TRUNC(BIN) always allows the maximum value. The other TRUNC option (STD) is similar to BIN, but not quite the same. However, if your compiler supports COMP-5 (Native Binary), then you should use this as the TRUNC option has no effect. Fullwords occupy 4-Bytes. Regards,
dbzTHEdinosauer

Global Moderator

Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

 Posted: Fri Apr 10, 2009 4:10 pm    Post subject: Gnanas N., The OP has the answer to one of his questions. how about the other one? you have saved him some research and any potential exposure to any other knowledge. But, then again, I may be too harsh. This is probably the only thing that he does not understand.
saagu

New User

Joined: 15 May 2008
Posts: 41
Location: Chennai

 Posted: Fri Apr 10, 2009 4:14 pm    Post subject: Thanks Gnanas and O'Boyle for your reply. Regards, Saagu
Gnanas N

Active Member

Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

Posted: Fri Apr 10, 2009 4:17 pm    Post subject:

Hi dbzTHEdinosauer,
 Quote: how about the other one?
Almost certainly he has to refer the manual as you suggested.
Bill O'Boyle

CICS Moderator

Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

 Posted: Fri Apr 10, 2009 4:50 pm    Post subject: Reply to: maximum value in S9(09) COMP I agree that the manual should be the initial source of information and I won't dispute this. In the case of the TRUNC option and how it deals with binary data, it can be rather "dicey" for newbies and perhaps, a basic overview as to how COBOL interacts with the TRUNC option was warranted. TRUNC is probably the most confusing and convoluted option in IBM's list of COBOL compiler options. It's been around since OS/VS COBOL (perhaps, even earlier) and it's gone through many different definitions of usage over the years, that someone could write a thesis on it. Regards,
dbzTHEdinosauer

Global Moderator

Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

 Posted: Fri Apr 10, 2009 5:50 pm    Post subject: Bill, I will be the last to complain of your posts. I took issue with just providing a value without providing the type of info that you gave. also, as I was composing my little ditty, you posted first.
Bill O'Boyle

CICS Moderator

Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

Posted: Fri Apr 10, 2009 6:32 pm    Post subject: Reply to: maximum value in S9(09) COMP

Dick said -
 Quote: I took issue with just providing a value without providing the type of info that you gave.

Dick,

I usually (but not always) just give them enough to spark their interest and force a review from the manual.

If I receive a reply saying that they're not too sure, I generally let a sleeping dog lie (and don't reply) because this indicates that they've not taken the time to look it up in the manual (or outright tell them) as I tried to imply and figure it out on their own.

I understand your frustration with some of these posts....

Regards,
saurabh39
Warnings : 1

Active User

Joined: 11 Apr 2008
Posts: 144
Location: Jamshedpur

 Posted: Sat Aug 07, 2010 12:40 am    Post subject: Reply to: maximum value in S9(09) COMP Hi, I was going through the TRUNC example given in the manual. For the first example, when I was working using binary, i was able to get the answer as -7621. And when I tried to reach the same result using, hex, i understood it will be E23B, but how E23B will represent -7621, i couldn't find out the answer. Please help. I am talking about the example given in link - Regards, Tushar
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8546
Location: Dubuque, Iowa, USA

 Posted: Sat Aug 07, 2010 12:57 am    Post subject: Hex E = binary 1110, flip the bits to get 0001 Hex 2 = binary 0010, flip the bits to get 1101 Hex 3 = binary 0011, flip the bits to get 1100 Hex B = binary 1011, flip the bits to get 0100 plus 1 gives 0101 1DC5 converted from hex is 7621. Since the bits were flipped, the number is -7621.
saurabh39
Warnings : 1

Active User

Joined: 11 Apr 2008
Posts: 144
Location: Jamshedpur

Posted: Sat Aug 07, 2010 10:01 pm    Post subject: Reply to: maximum value in S9(09) COMP

@Robert - Thanks again.

I understood, that the Complement of the truncated value should be found, to get the correct value. and even link says & i quote
 Quote: Because the new truncated value overflowed into the sign bit of the binary halfword, the value becomes a negative number.

Now the question arises, how did COBOL knew, that negative value is to be printed, and also, from the IBM link's quote, I feel whenever these type of truncation or this situation arises, only negative number will be displayed, as everytime truncated value will overflow into sign bit.

Please let me know, If my question is not clear
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8546
Location: Dubuque, Iowa, USA

 Posted: Sat Aug 07, 2010 11:49 pm    Post subject: You are misunderstanding the text and its application. The sign bit of a COMP variable is merely the first bit. When the truncated (half-word) move is done, and the moved result has the first bit turned on, the value is negative -- there' is nothing for COBOL to "know" since this is inherent in the way COMP variables are defined and work. If you try the TRUNC(BIN) example from the text with 94779 instead of 123451, the resulting value will be positive (I haven't tested with the compiler but the value should be 29243).
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Write 9(07) comp-3 data into output file clearskynot DFSORT/ICETOOL 4 Thu Apr 16, 2020 11:00 pm Increase the Maximum Length of LRECL ... Dhineshpondy7 JCL & VSAM 5 Wed Aug 07, 2019 6:23 pm S9(11)V9(02) to S9(9)V9(2) COMP-3 sprikitik SYNCSORT 2 Tue Oct 23, 2018 6:19 pm Comp interview questions Deepak1518780 Mainframe Interview Questions 5 Sat Sep 22, 2018 7:26 pm Replace comp-3 field value to comp-3 ... dharmaraok DFSORT/ICETOOL 5 Fri Sep 14, 2018 3:46 pm

 © 2003-2020 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us