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

Re: gnubol: The sign-nibble question



Hello Bill,

Thank you for this detailed message. You will find my answers intermixed.

"William M. Klein" wrote:

> The "problem" that "display" numerics in ASCII are X"30" thru X"39" (as
> opposed to the mainframe X"F0" thru X"F9").  Therefore, the question becomes:
>
> A) If you pack an (ASCII DISPLAY) X'393837'field - should you get
>      X'9837'
>        or
>      X'98F7'
> (given the fact that the MOST common packed-decimal routines "assume" IBM
> compatible sign-nibbles, the latter MAY be desirable - but non-intuitive)

No, both of your possibilities are false. Sorry, The PACK instructions works
exactly as I have described. So your X"393837" containing field would result
after a PACK command in X"9873". Let's have a look at the way it works :
- your input field consist of three bytes, which contains x"39", x"38" and
x"37".
- your output fields right-hand end-address' right nibble is filled with the
left nibble of the right-hand end-address of the input field as being the sign,
so the output field (assumed it is 2 bytes long) contains x"0003"`.
- then the right nibbles of the input field are inserted from right to left in
the output field so you will get x"9873".

In this stage the left nibbles are disgarded. The PACK instruction is not
interested in their contents.

Now it is not my decision if the sign character should be represented by the
value 3 in the right nibble of the right-hand end-address of the output field.
That is up to the GNU-Cobol software developpers. But at least I would like to
tell you that it might be important to support all those old Cobol code and the
files which were build with it. It would not hurt the old programs if you decide
to assign a positive value to the x".3" sign as that value didn't have a meaning
in those oldtimer programs. It will hurt many applications if you decide not to
support the values x".F", x".C" as positive signs and x".B" and x".D" as
negative signs.

A bit off topic but not all mainframes were EBCDIC based systems. Honeywell has
build a number of ASCII based mainframes.


> B) If the latter is what you want, then should X'3132' be considered
> equivalent to X'F1F2' - or not?  Should both "pass" an IF NUMERIC test?

These two are equivalent when we are talking about DISPLAY fields. First, when
data is transferred between systems the ASCII codes will be translated to EBCDIC
codes (if necessary) and reverse. So, the EBCDIC x"F1F2" is equivalent to the
ASCII x"3132". On an EBCDIC based system the first will pass the IF NUMERIC test
and the second won't, on an ASCII based system the opposite is true.

There have been times that I build this kind of software and those times were
interesting. This sort of tests did I implement with a small translation table
of 256 bytes and the TRT (translanslate and test) command.


> C) Also, it is common (but not universal) in ASCII COBOL implementations to
> have X'3' as the sign nibble for BOTH unsigned and positive numbers.  What
> should the GNU COBOL do about this?

See my comments at A).

Best regards,

Fred Mobach



--
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.