COBOL Decimal Numbers


There are two type of formats for decimal numbers:

1. Zoned Decimal
2. Packed Decimal

1. Zoned Decimal Numbers
-- each byte present 1 numeric value.
-- the sign mark is placed at last byte ( F means an unsigned, C means a positive, D means a negative)
-- for example
    123 => 0x F1 F2 F3 ("123")
    +1234 => 0x F1 F2 F3 C4 ("123D"), 0xC4 == 'D'
    - 12345 => 0x F1 F2 F3 F4 D5 ("1234N"), 0xD5 == 'N'

With EBCDIC coding, '0' = 0xF0, '1'=0xF1, '2'=0xF2, ..., '9'=0xF9

2. Packed Decimal Numbers (COMP-3)
-- each byte present 2 numeric values (but the last byte)
-- the sign is placed at the most-right 4 bits; so the last byte present a numeric value and the sign mark
-- for example
    123 => 0x 12 3F
    +1234 => 0x 01 23 4C
    - 12345 => 0x 12 34 5D
(Compared with ZD, where the sign mark is placed at first half-byte, PD use second half-byte as sign mark)

EBCDIC please refer to  https://zh.wikipedia.org/wiki/EBCDIC

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值