0000是有效的EBCDIC签名值吗?

发布于 2025-02-07 12:54:25 字数 105 浏览 3 评论 0原文

我们有一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笔芯 2025-02-14 12:54:27

简短答案

是,'0000''000 {'表示正零。 '000}'表示负零。

详细的答案

包装的十进制数字通常在IBM大型机系统上使用,因为处理器具有一组小数指令。这些说明假定其操作数遵守了存储中十进制装箱数字的规则。参见 ibm z/架构操作原理,第8章“小数项” >。

总而言之,十进制装箱的数字具有数字,即0x0 - 0x9,在每个字节的每个nibble中,除了最右边的字节(最右边的nibble)中的右nibble。最右边的nibble保留了符号,该符号优先0xc for -aSTIS,而0xd对于负值。该系统还接受0xa0xe0xf作为正符号,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值,即0x00x1,...,...,0x9

因此,positvie值导致:

  • 0xc00xc1,...,0xc9

,负值导致

  • 0xd00xd1,...,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 ,请正确处理符号您可以:您可以:

  • 在EBCDIC中,用0xf覆盖右字节的左nibble,以确保它是真正的EBCDIC字符数字。
  • 在ASCII中,用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 values 0xC for positive, and 0xD for negative values. The system also accepts 0xA, 0xE, and 0xF as positive signs, and 0xBas 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:

  • positive values: 0xdC --> 0xCd
  • negative values: 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):

  • positive zero: 0x0A --> 0xA0, which is 'µ'
  • positive zero: 0x0E --> 0xE0, which is '\'
  • positive zero: 0x0F --> 0xF0, which is '0'
  • negative zero: 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:

  • In EBCDIC, overlay the left nibble of the right most character byte with 0xF to make sure it is a real EBCDIC character digit.
  • In ASCII, overlay the left nibble of the right most character byte with 0x3 to make sure it is a real ASCII character digit.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文