You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@daffodil.apache.org by "Costello, Roger L." <co...@mitre.org> on 2020/04/20 14:38:59 UTC

What is a "zoned" textNumberRep?

Hi Folks,

textNumberRep :: standard | zoned

"standard" means the number is represented by a sequence of character digits. Right?

"zoned" means ??? Can you provide an example of a zoned number? Can you point me to a web page that explains zoned numbers?

/Roger

Re: What is a "zoned" textNumberRep?

Posted by "Beckerle, Mike" <mb...@tresys.com>.
Ah, a true "data archaeology" topic.

Here's a link.

https://community.microfocus.com/t5/Net-Express-Server-Express/What-is-a-Zoned-Decimal-and-how-is-it-represented-in-COBOL/ta-p/1758317

This is COBOL stuff.  The MicroFocus Cobol online materials are a great source of info.

I am dating myself here, but zoned decimal originated on IBM computers in the 1960s. Honestly I didn't encounter this stuff until like 1985.

The instruction sets of those CPUs support decimal numbers in two forms: packed, and zoned.

Zoned is actually just text, in EBCDIC where the numbers 0,2,3... are reprpresented by bytes 0xF0, F1, F2, F3.... Those F nibbles are called the "zones".

So operating on decimal text just requires that the instruction set ignore the F nibble and operate on the base 10 digit part.

Except, there's pesky decimal points, and minus signs to deal with.

So the "implied decimal point" is the way decimal math works. There's no decimal point in the text string. Just digits.

And the sign is handled by using the F nibble in the last digit - changing it to C for plus, D for minus, and F for unsigned which is equivalent to C ultimately.  Since this dates from computers with punch cards, this was called "overpunched" sign, but exactly how one does overpunching, I fortunately never had to learn.

This data format (zoned, trailing overpunched sign) is still heavily used. It is the default you get in COBOL if you don't specify anything specific about a number in Cobol.

So, the plot then thickens.

Take a EBCDIC zoned number, overpunched trailing sign like -123.45. That's F1 F2 F3 F4 D5 bytes. Now treat those as text and it looks like "1234)" The ")" is EBCDIC D5. Now translate EBCDIC to ASCII. You get bytes 31 32 33 34 29. That last 29 is an ASCII ")". Notice that the zone is not 3, and the decimal value nibble is not 5.

This is what DFDL calls dfdl:textZonedSignStyle='asciiTranslatedEBCDIC'.

There are 3 other variants of how zoned numbers work and I won't repeat the details here, but the dfdl:textZonedSIgnStyle property has the knarly details.


________________________________
From: Costello, Roger L. <co...@mitre.org>
Sent: Monday, April 20, 2020 10:38 AM
To: users@daffodil.apache.org <us...@daffodil.apache.org>
Subject: What is a "zoned" textNumberRep?

Hi Folks,

textNumberRep :: standard | zoned

"standard" means the number is represented by a sequence of character digits. Right?

"zoned" means ??? Can you provide an example of a zoned number? Can you point me to a web page that explains zoned numbers?

/Roger

RE: What is a "zoned" textNumberRep?

Posted by "Costello, Roger L." <co...@mitre.org>.
Hi Folks,

I found a web site that says this about zone decimal numbers:

zoned decimal specifies a method of encoding decimal numbers in which each digit requires one byte of storage. The last byte contains the number's sign as well as the last digit. Zoned decimal data produces a printable representation.

Suppose that I have a text data format and an instance contains the number nine. Suppose the encoding property specifies the value ASCII. If I view the instance in a hex editor, I see these hex digits:

	39

If I view the instance in a text editor, I see this:

	9

Now, suppose the data format uses "zoned" numbers. From the above definition of zoned decimal, I might imagine that for an instance having the value nine a hex editor would show this:

	09

If I viewed that in a text editor, it would show a tab (in ASCII hex 9 is the tab symbol). A tab symbol is a very odd way to represent the number 9. 

Zone numbers make no sense to me. Help!

/Roger

-----Original Message-----
From: Costello, Roger L. <co...@mitre.org> 
Sent: Monday, April 20, 2020 10:39 AM
To: users@daffodil.apache.org
Subject: What is a "zoned" textNumberRep?

Hi Folks,

textNumberRep :: standard | zoned

"standard" means the number is represented by a sequence of character digits. Right?

"zoned" means ??? Can you provide an example of a zoned number? Can you point me to a web page that explains zoned numbers?

/Roger