# Data representation with negative values

Author Message
Raghu navaikulam

Active User

Joined: 27 Sep 2008
Posts: 193
Location: chennai

 Posted: Tue Jan 14, 2014 9:36 am Hi all Could anyone please help me in understanding how -32 is represented with 03K. Regards Raghu
Pandora-Box

Moderator

Joined: 07 Sep 2006
Posts: 1566
Location: Andromeda Galaxy

 Posted: Tue Jan 14, 2014 10:34 am Pleaae explain I coudnt understand
steve-myers

Active Member

Joined: 30 Nov 2013
Posts: 862
Location: The Universe

 Posted: Tue Jan 14, 2014 10:40 am I presume the text you are showing is text defined as "zoned decimal." The hexadecimal form of your field is F0F3D2. Now be patient with me, because we are going back to ancient history. Back in the days of punched card based data processing we had machines called card sorters. You have probably seen them in old movies. The operator puts a bunch of (presumably) punched cards into the machine and presses the start button. The machine sucks up the cards and distributes them to various pockets. The actor pulls out one of the cards, which presumably has the information he needs and the action continues. Now what happened. A traditional punched card has 80 "columns" of data, in 12 "rows." By convention, from the top of the card, the first two rows were not punched for numeric data, and were punched for letters and punctuation. The top row was called a 12 punch, and the next row an 11 punch. The remaining rows were punched for numbers, 0 through 9. Another convention: for numeric, signed data, the top row for the last column of a number was punched to indicate a positive number, and the second row was punched to indicate a negative number. Again, by convention, a column with 12-1 punched is the letter A, 11-1 is the letter J, 11-2 is K, and so on. Each run through of a card sorter sorted one column. It could be set to distinguish the 12/11 punches, or the numeric fields. Now when a punched card reader read cards, it would translate a 0 punch to F0, a 1 punch to F1, a 12-1 punch to C1, an 11-1 punch to D1, and so on. Now, get out your Principles of Operation and turn to where it describes signs for packed decimal and zoned decimal data. In zoned decimal data the sign is the first 4 bits of the last byte of data: Cx or Fx is positive, Dx is negative. Similarly, with packed decimal data xF or xC is positive, xD is negative in the last byte of packed decimal data. Now, I hope you see where this convention comes from.
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

 Posted: Tue Jan 14, 2014 1:14 pm To complement what Steve has said, you have a PIC S999 (or S9*3), same thing). If you DISPLAY that, or otherwise include it in any output, it will appear as 3K when it contains the value -32. When you look at a value like that, you need to "decode" it yourself to know that it contains (in this case) -32. If you look in this forum you will see a "Sticky" which maps the values. You can experiment with COMP-3/PACKED-DECIMAL and COMP/COMP-4/COMP-5/BINARY as well. With positive numbers you just get a di fferent set of "letters". Note the representation of +/- zero. With unsigned numeric PICtures, you just have the numbers, as there is no other information to show you.
Raghu navaikulam

Active User

Joined: 27 Sep 2008
Posts: 193
Location: chennai

 Posted: Tue Jan 14, 2014 10:19 pm Hi Thanks to all for your response. What I am looking for is the table, which I got from Bill's "Sticky". Thanks Bill. Thanks to everybody. Regards Raghu
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Forum Replies Similar Topics How to find which file contains my se... DFSORT/ICETOOL 6 Changing Data Type SYNCSORT 4 Copying data from prev record using SORT SYNCSORT 19 how to get total count from numeric d... SYNCSORT 9 Missing Negative sign in COBOL COBOL Programming 6