What are those numeric definition?
Author Message
What are those numeric definition?

Here are what I understand now:
S stands for sign; V stands for decimal point; So S99V9(4) stands for
such format as -12.4356. (Correct me if I am wrong).

But I am confused by some other numeric definitions:
S99ppV
s9PP
B9
S9(2)99 - is it same as S99999 (there are 5 9's)? Does that say there
are 1+2+2 nines?
S99(4) - is it same as S999999?
SVp99 sync - ?
Sp99
SP(2)99

What are P, B, sync, etc?

Can anyone help me to understand each of the above definition? Thanks a
lot!

Steve

Wed, 25 Feb 2004 03:16:19 GMT
What are those numeric definition?

Quote:
> S stands for sign; V stands for decimal point; So S99V9(4) stands for
> such format as -12.4356. (Correct me if I am wrong).

You are correct. S does stand for a sign, and V is for place holding a
decimal. When using defining your PIC clause, however, you are either
creating an area for internal storage in the computer, or an area for
displaying data (as in a printed report or a video display).

S and V are used for *internal* storage for numeric and packed numeric
information. For example:

01 Data-fields.
05 Field-A    PIC S99V9(4)              <-- Numeric storage using 6
bytes (the sign is in the top half of the last byte)
05 Field-B    PIC S99V9(4) COMP-3 <-- Numeric packed using 4 bytes (the
sign is in the bottom half of the last byte)
05 Field-C    PIC 99V9(4)                 <-- same as field-a, except
with no sign storage, and the number will always be positive even if you
move a negative number here

For decimals and signs for displaying data, you need the . (period
character) where your decimal place is to go, and +, -, DB or CR either at
the front or back of the string to indicate your sign.

Lets move your -12.4356 value to the following:

01 Data-output.
05  Output-A PIC 99.9(4)-           <- If moved here, your displayed
output would be 12.4356-
05  Output-B PIC 99.9999-          <- You get the same thing
05  Output-C PIC 9(2).9(4)-         <- Again, the same thing.
05  Output-D PIC -9(2).9999        <- Here, you get -12.4356 on the
output.

Note the numer in the parenthesis indicates how many characters to use just
before it, so:
9(6) is the same as 999999
9(1) is the same as 9

P is a decimal scaling position. You can only use it immediately to the left
or right of the decimal position, and for either internal storage or
display. So, if you move 123 to a field with PIC 999PPP, you essentially
would get 123000. P positions do not take up internal storage, but do count
toward your maximum 18 numeric positions.

B inserts a blank character for display output only. Moving 567 to a field
with PIC 9B9B9 would give you 5 6 7 (five-space-six-space-seven).

So, lets's look at your sample pictures...

Quote:

> But I am confused by some other numeric definitions:
> S99ppV

This is valid for internal storage.

Quote:
> s9PP

This is okay, too. Internal.

Quote:
> B9

Fine. External.

Quote:
> S9(2)99 - is it same as S99999 (there are 5 9's)? Does that say there
> are 1+2+2 nines?

S9(2)99 is the same as S9999 - four numeric positions. It would be better to
say S9(4), although I think a compiler would take it the other way.

Quote:
> S99(4) - is it same as S999999?

S99(4) is the same as S99999 - five numeric positions. Better to say S9(5),
I think.

Quote:
> SVp99 sync - ?

Valid for internal storage. The term SYNC forces the synchronation of the
numeric field you're specifying to line up on a fullword or doubleword
boundary. Some would say the term is archaic, but it's really not in the
mainframe realm when dealing with files from other systems, processors,
etc.You're probably not going to use this term too often.

Quote:
> Sp99

Not valid. P must be immediately left or right of the decimal position.

Quote:
> SP(2)99

Not valid either. Same reason.

There are other characters used that you didn't mention:
Z is for zero suppression for output display. Moving 456 to a PIC ZZZ9999
would give you 0456 on the output (three spaces in the front).

0 (zero) inserts a zero for output display.
/ (slash) inserts a / for output display.
\$ floats a dollar sign to the position immediately in front of the first
number printed on output. For example, moving 124.55 to PIC \$\$\$\$\$.99 would
give you \$124.55

* works like the \$ except is strings asterisks along for things like check
protection. Moving 123.77 to a PIC *******.99 would give you ****123.77 on
the output.

Hope this helps.

Gonzo

Wed, 25 Feb 2004 15:52:27 GMT
What are those numeric definition?
To the GROUP - please note that Steve has said that he is a beginner and
LOOKING for a good "tutorial web site" - in another post.  Therefore, don't
assume that he is asking for us to do his homework or similar (even if he
might be fooling us <G>).

To Steve - I think that you should pick up a book.  This group usually comes
up with several - one of which is Thane Hubbell's "Sam's Teach Yourself
COBOL in 24 Hours" book (24 SEPARATE hours, not one day).  You might want to
check out the COBOL FAQ that mentions several (many) books.  It is at:

http://cobolreport.com/faqs/cobolfaq.htm

You are correct that getting a handle on all the variations of symbols in
the PICTURE clause is important - but I think it is best to learn this in
the context of a "structured" introduction to COBOL.

--
Bill Klein
wmklein <at> ix.netcom.com

Quote:
> Here are what I understand now:
> S stands for sign; V stands for decimal point; So S99V9(4) stands for
> such format as -12.4356. (Correct me if I am wrong).

> But I am confused by some other numeric definitions:
> S99ppV
> s9PP
> B9
> S9(2)99 - is it same as S99999 (there are 5 9's)? Does that say there
> are 1+2+2 nines?
> S99(4) - is it same as S999999?
> SVp99 sync - ?
> Sp99
> SP(2)99

> What are P, B, sync, etc?

> Can anyone help me to understand each of the above definition? Thanks a
> lot!

> Steve

Wed, 25 Feb 2004 16:06:09 GMT
What are those numeric definition?

Quote:
> Here are what I understand now:
> S stands for sign; V stands for decimal point; So S99V9(4) stands
for
> such format as -12.4356. (Correct me if I am wrong).

Correction: "V" stands for an IMPLIED decimal point (the decimal point
does not actually exist as a character). That is, every time the
computer uses the data defined as above, the computer is to assume, in
a string of six digits, that there is a decimal point after the second
digit. Likewise, the sign is (usually) implied. The "S" signals the
compiler that after an arithmetic operation the computer is to leave
the algebraic sign alone and not take the absolute value of the
result.

Quote:

> But I am confused by some other numeric definitions:
> S99ppV

"45" is treated as if it were +/-4500. ("P" is the first letter in the
word "Predo," - Esperanto for "Scaling Factor. Just kidding.)

Quote:
> s9PP

"3" is treated as if it were +/-300

Quote:
> B9

Print a single digit with a leading space, making two characters
printed.

Quote:
> S9(2)99 - is it same as S99999 (there are 5 9's)? Does that say

there
No. Four "9"s means a four-digit number. "S" means the field is to be
treated as possibly having negative or positive values.

Quote:
> are 1+2+2 nines?

No, there are ones and twos (?)

Quote:
> S99(4) - is it same as S999999?

No. There are FIVE 9s in the picture 9 + (9*4)

<snip>

Numeric data definitions are of two classes:
1. How things are represented or handled internally, and
2. How things are displayed (Editing symbols).
Unfortunately, there is some overlap (i.e., "9") - the two sets of
symbols are not mutually exclusive. So, you must first decide, in
defining a picture, whether the data item is to be used internally (a
counter, key, subtotal, index, etc.) or whether you intend to have the
data item printed or displayed for human consumption. In general, you
can't do (or at least should avoid) arithmetic on edited data and
displayed internal representations look goofy.

You should know about the existence of {*filter*} symbols, but generally
avoid their use. In many, many years of programming, I've used the
scaling factor (P) maybe twice, a blank (B) maybe 0.5% of the time,
"SYNC" never, JUSTIFIED never, CR/DB maybe once, "Z"  and '-' a lot
and "S" at every opportunity.

Here's a hint: If you cannot do arithmetic on the data item, the datum
is NOT A NUMBER and numeric definitions should be shunned. Like:
Social Security Numbers, telephone numbers, addresses, patent numbers,
account numbers, and numbers on credit cards.

Thu, 26 Feb 2004 00:14:26 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages