解码二进制编码的十进制 [英] Decode a Binary Coded Decimal

查看:143
本文介绍了解码二进制编码的十进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字段图片X(03),其中的日期为X'160101'格式yymmdd。

I have a field pic X(03) with a date in it as X'160101' format yymmdd.

我想知道如何将其转换为图片x(06)。

I will like to know how to convert it to pic x(06).

到目前为止,我尝试将其移回9(03)分量并将
9(03)分量移至9(06),但没有用。

So far I tried to move it back to a 9(03) comp and move the 9(03) comp to a 9(06) but it didn't work.

我该怎么做?

推荐答案

如果搜索stackoverflow,您应该找到答案(已经得到了答案)。

If you search stackoverflow, you should find the answer (this has already been answered).

但是请创建一个字段,例如(my-date- x保留日期):

But Create a fields like (my-date-x holds the date):

   03  my-date-x            pic x(3).
   03  my-date-9            pic 9(6).

   03  date-ymdv0           pic 9(6)v9 comp-3.
   03  date-x               pic x(3) redefines date-ymdv0.

代码是

   Move 0                   to date-ymdv0 
   Move my-date-x           to date-x
   Move date-ymdv0          to my-date-9

它起作用的原因是用于 9(6)v9 comp3 160101存储为x'1601010c'
,这就是您所拥有的(最后加上一个0c)。

The reason it works is for 9(6)v9 comp3 160101 is stored as x'1601010c' which is what you have (+ a 0c at the end).

这篇关于解码二进制编码的十进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆