将解压缩的 Packed Decimal Comp-3 数据转换为双精度数
我有一个固定宽度的文本文件,它已从 Comp-3 数据解包为固定宽度的字符串。
我需要知道如何解释以下字段:
FIELD-NAME-1 PIC S9(15)V9(3) COMP-3.
FIELD-NAME-2 PIC S9(3)V9(8) COMP-3.
FIELD-NAME-3 PIC S9(3)V9(6) COMP-3.
这些字段在我的平面文件中显示为:
FIELD-NAME-1 0123456789123456780
FIELD-NAME-2 01234567890
FIELD-NAME-3 012345670
我需要知道上面的数字代表什么。
这是正确的吗:
FIELD-NAME-1 123456789123456.780 --> The first 0 means +ve?
FIELD-NAME-2 012.34567890
FIELD-NAME-3 012.345670
感谢您的帮助。 火腿
I have a fixed width text file, which has been unpacked from Comp-3 data into fixed width strings.
I need to know how to interpret the following fields:
FIELD-NAME-1 PIC S9(15)V9(3) COMP-3.
FIELD-NAME-2 PIC S9(3)V9(8) COMP-3.
FIELD-NAME-3 PIC S9(3)V9(6) COMP-3.
These appear in my flat file as:
FIELD-NAME-1 0123456789123456780
FIELD-NAME-2 01234567890
FIELD-NAME-3 012345670
I need to know what numbers the above would represent.
Is this correct:
FIELD-NAME-1 123456789123456.780 --> The first 0 means +ve?
FIELD-NAME-2 012.34567890
FIELD-NAME-3 012.345670
Thanks for the help.
Ham
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
S9(15)V9(3)需要19个半字节(实际上是20个半字节,因为它必须产生偶数个半字节)来存储:
该符号通常以
C
或D
nybble 的形式出现在末尾,因此这个问题的答案完全取决于解包的内容。您的第一个示例实际上具有正确的位数,没有符号,因此我担心您的陈述,即其中一个数字代表符号。 要么是这样,要么你漏掉了“9”。 另外两个示例对于符号和数字部分都有足够的数字。
最好的选择是,看看是否可以输入负数(以及其他测试数据,例如 1),看看它会生成什么。
The S9(15)V9(3) requires 19 nybbles (20 in reality since it must make an even number of nybbles) to store:
The sign usually appears at the end as a
C
or aD
nybble so the answer to this question depends entirely on what did the unpacking.Your first example actually has the right number of digits without the sign so I'd be concerned with your statement that one of them represented the sign. Either that, or you've left off the "9". The other two examples have enough digits for both the sign and numeric part.
Best bet, see if you can get a negative number (and other test data like 1) into there to see what it generates.