[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [GNU-COBOL] New to list





> Some comments are permitted, I hope.

All things are permitted.

> Alphanumeric fields : PIC strings contains A, X and 9 characters !

Alphanumeric, or alphanumeric edited?

> Fixed point with sign :
> PIC  strings with S as sign indicator, 9 as placeholder for the numeric
> digits, V for the place of the assumed decimal point and P for scaling.

Internally, yes.  Numeric-edited fields have different possibilities and
although they can only hold numbers, they can't (normally) be used in
doing arithmetic.

> I never saw A0-A9 :-). Do you want to know how this translates to
> ASCII?  That's difficult as I've never seen an official translation
> tabel for the whole EBCDIC set.

Really?  I have a full code table (00 to FF) translating from decimal to
hex to binary, and which has the relevant codes for BCDIC, EBCDIC,
ASCII, 7-track tape BCDIC, card code EBCDIC, and another column that I'm
not evens sure *what* it is.  (The heading in the first page says "Inst.
(RR)" and on the second page it's "Inst. (RX)"; I think it has something
to do with assembler.)  If I remember correctly, that came from one of
those IBM pocket manual thingys.  If you'd like a copy, I think I could
send you one without getting *too* far into copyright infringement.

> If the field is in USAGE IS COMP format the field is a binary numeric
> field signed as usual on the target system.

True.  The DOS/VSE compiler that I'm working on has a little additional
quirk (which I think is also true on other compilers) that Gnubol may or
may not want to implement.  Remember that the COMP field will take up 2,
4 or 8 bytes of storage depending on the PIC clause; a field defined as
PIC S9(4) COMP will take up two bytes of storage, and so can hold a
number up to around 32,767.  Even though it is defined as a 4-digit
field, we (i.e., programmers where I work) often use those fields to
hold five-digit numbers (below 32767, of course.)  No errors are
generated, although a warning is issued in the compile listing.

> If the field is in USAGE IS COMP-3 format (the well-known packed decimal
> format) each byte holds two digits except the right-hand end-address,
> where the right digit represents the sign : in hex code F and C
> represents a positive value and B, D ans E represents a negative value.

Essentially, yes.  The common formula used to figure out how many
storage bytes a COMP-3 field takes up is to divide the number of digits
by 2 and round up.  (Hence,  a PIC S9(7) COMP-3 field would take up 4
bytes of memory.)

> Fixed point without sign :
> PIC  strings with 9 as placeholder for the numeric digits, V for the
> place of the assumed decimal point and P for scaling.
> If the field is in USAGE IS DISPLAY mode all cyphers are represented by
> 0-9 and the value is assumed to be positive.
> The usage of the USAGE IS COMP format is impossible as it always assumes
> a sign.

No, it isn't impossible; it's fairly common actually.  Just like USAGE
IS DISPLAY, it's always assumed to be positive, and on many systems will
then be able to store a higher value.  (For instance, the PIC S9(4) COMP
field mentioned above could store a value of up to 65,535 if declared as
unsigned.)

> If the field is in USAGE IS COMP-3 format (the well-known BCD code
> format) each byte holds two digits.

Except the rightmost byte which holds one plus a sign indicator, as you
mentioned above.

> The effect of SYNC in combination with USAGE IS COMP depends upon the
> length of the field : alignment is done at the length of the field. If
> the field is 2 bytes in length the alignment is done at a 16-bit
> boundary, otherwise it's done at a 32-bit boundary. Note that (as far as
> I know) Cobol support numeric variables at a maximum length of 18
> cyphers.

You should be also point out, for anybody reading this who might not be
as familiar with COBOL, that the SYNC clause can *only* be used with the
COMP clause.

> Do you want to know how Cobol works with floating-point variables ? Just tell
> me, but I have to investigate it as I've never used it before in Cobol :-).

What do you mean by floating-point variables?  Things like PIC 99V9?

-- 
David R. Ondrejko - EDI/Referral - Safelite Glass Co.
 Mathematician by training - Programmer by trade - Philosopher by nature
 Genius by genetics - Atheist by conviction - Hedonist by desire!

--
This message was sent through the gnu-cobol mailing list.  To remove yourself
from this mailing list, send a message to majordomo@lusars.net with the
words "unsubscribe gnu-cobol" in the message body.  For more information on
the GNU COBOL project, send mail to gnu-cobol-owner@lusars.net.