Thanks Mike. Would it be correct to say that for an instance of a text data 
format that uses zone numbers, you would not use a Notepad (or Notepad++ or any 
other "normal" text editor) to view the instance? That is, you would need a 
special editor that understands zoned numbers to view the instance. Is that 
correct?

/Roger

From: Beckerle, Mike <mbecke...@tresys.com>
Sent: Monday, April 20, 2020 11:57 AM
To: users@daffodil.apache.org
Subject: [EXT] Re: What is a "zoned" textNumberRep?

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. <coste...@mitre.org<mailto:coste...@mitre.org>>
Sent: Monday, April 20, 2020 10:38 AM
To: users@daffodil.apache.org<mailto:users@daffodil.apache.org> 
<users@daffodil.apache.org<mailto: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

Reply via email to