0000是有效的EBCDIC签名值吗?
我们有一个ASCII文件,其格式为EBCDIC签名字段。
有时,该值为0000,而我期望000 {或000}。
0000在ASCII文件中是否有效eBCDIC签名值?
We have an ASCII file with numbers formatted as EBCDIC signed fields.
Sometimes the value is 0000 while I would expect 000{ or 000}.
Is 0000 a valid EBCDIC signed value within an ASCII file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简短答案
是,
'0000'
和'000 {'
表示正零。'000}'
表示负零。详细的答案
包装的十进制数字通常在IBM大型机系统上使用,因为处理器具有一组小数指令。这些说明假定其操作数遵守了存储中十进制装箱数字的规则。参见 ibm z/架构操作原理,第8章“小数项” >。
总而言之,十进制装箱的数字具有数字,即
0x0
-0x9
,在每个字节的每个nibble中,除了最右边的字节(最右边的nibble)中的右nibble。最右边的nibble保留了符号,该符号优先0xc
for -aSTIS,而0xd
对于负值。该系统还接受0xa
,0xe
和0xf
作为正符号,0xb
作为负符号。的人类可读,则可以使包装的
如果您需要制作十进制包装数字 十进制人物可读,可以使用
umpk
(unvake)处理器指令。此指令将每个字节转换为nibble的最右字节,除了nibble nibble,以相应的ebcdic字符数字,即0x0
- >'0'
(=0xf0
)0x1
- >'1'
(=0xf1
)0x9
- >'9'
(=0xf9
)大多数字节的处理方式都不同,因为它在左nibble中包含一个数字,符号在右nibble中。通过简单地交换nibbles来改变此字节。对于具有首选符号值的十进制数字,这是:
0xdc
- >0xcd
0xdd
- >0xdd
其中小写
d
表示数字nibble值,即0x0
,0x1
,...,...,0x9
。因此,positvie值导致:
0xc0
,0xc1
,...,0xc9
,负值导致
0xd0
,0xd1
,...,0xd9
。相应的结果EBCDIC字符
'{'
,'a'
,'b'
,...,'i'i'(正值)
'}'
,'j'
,'k'
,...,'r'r'< /code>(负值)
要使数字真正可读,然后程序通常用
0xf
覆盖该最后一个字符的左侧nibble,以使其成为读取EBCDIC字符数字。这称为划分的十进制格式。到目前为止,仅使用了首选的符号代码。如果将使用备用的符号代码(如上所述),则可能会出现各种其他字符。例如,使用替代符号代码的数字零的变化将显示(在EBCDIC中):
0x0a
- &gt;0xa0
,是'µ'
0x0e
- &gt;0xe0
,是'\'
0x0f
- &gt;0xf0
,它是'0'
0x0b
- &gt;0xb0
,是'^'
如果执行打开包装的十进制数字
的程序确实 not ,请正确处理符号您可以:您可以:
0xf
覆盖右字节的左nibble,以确保它是真正的EBCDIC字符数字。0x3
覆盖了右字节的左nibble,以确保它是真正的ASCII字符数字。Short Answer
Yes, both
'0000'
and'000{'
denote a positive zero.'000}'
denotes a negative zero.Detailed Answer
Packed decimal number are often used on IBM mainframe systems, since the processor has a set of decimal instructions. Those instructions assume that its operands follow the rules for decimal packed numbers in storage. See IBM z/Architecture Principles of Operation, Chapter 8 "Decimal Instructions".
In summary, a decimal packed number has digits, i.e.
0x0
-0x9
, in every nibble of every byte, except for the right nibble in the rightmost byte (rightmost nibble). The rightmost nibble holds the sign, which has preferred values0xC
for positive, and0xD
for negative values. The system also accepts0xA
,0xE
, and0xF
as positive signs, and0xB
as negtive sign.Making Packed Decimal Human Readable
If you need to make a decimal packed number human readable, you can use the
UNPK
(unpack) processor instruction. This instruction transforms each byte, except for the rightmost byte, nibble by nibble, to the corresponding EBCDIC character digit, i.e.0x0
-->'0'
(=0xF0
)0x1
-->'1'
(=0xF1
)0x9
-->'9'
(=0xF9
)The rigtmost byte is handled differently, since it contains a digit in the left nibble and the sign in the right nibble. This byte is transformed by simply exchanging the nibbles. For decimal numbers with preferred sign values, this is:
0xdC
-->0xCd
0xdD
-->0xDd
where the lowercase
d
denotes the digit nibble value, i.e.0x0
,0x1
, ...,0x9
.So, positvie values lead to:
0xC0
,0xC1
, ...,0xC9
and negative values lead to
0xD0
,0xD1
, ...,0xD9
.The corresponding resulting EBCDIC characters
'{'
,'A'
,'B'
, ...,'I'
(positive values)'}'
,'J'
,'K'
, ...,'R'
(negative values)To make the numbers really human readable, programs then usually overlay the left nibble of this last character with
0xF
to make it a read EBCDIC character digit. This is called zoned decimal format.So far, only the preferred sign codes were used. If alternate sign codes (as noted above) would be used, all sorts of additional characters might appear. For example, variations of the number zero with alternate sign codes would show (in EBCDIC):
0x0A
-->0xA0
, which is'µ'
0x0E
-->0xE0
, which is'\'
0x0F
-->0xF0
, which is'0'
0x0B
-->0xB0
, which is'^'
Handling Imporperly Unpacked Numbers
If the program doing the unpacking of packed decimal numbers does not handle the sign nibble correctly for human redability, you can:
0xF
to make sure it is a real EBCDIC character digit.0x3
to make sure it is a real ASCII character digit.