zoukankan      html  css  js  c++  java
  • COMP-3

    COMP-3 再次探讨
    2010-10-31 21:33

    今天在hex中对9型和comp-3深入研究了下。

    9型:

    在普通情况下:F0 --> F9 表示 1 --> 9

    在S9最后一位:正数:C1 --> C9   表示 1 --> 9

                              负数 D1 --> D9   表示 1 --> 9

    comp-3型:

    普通情况下:hex中一个数就代表comp-3中一个数

    在有S的最后一位:正数:?C

                         负数:?D

    无S的最后一位:?F  

    2010-09-19 15:20

    Comp-3 fields in COBOL

    Comp-3 fields are denoted in COBOL with the "usage is" clause after the PIC, like this:

    PIC S9(5) usage is computational-3.

    However, the "usage is" is not required and seldom used, and "computational-3" is usually abbreviated "comp-3", so you more commonly see:

    PIC S9(5) comp-3.

    The COBOL PIC, or picture, for a comp-3 packed field specifies the number of digits after unpacking. The actual number of bytes occupied in the file is about half that. To calculate the number of bytes from the PIC, add 1 (for the sign) to the total number of digits, divide by 2, and round up if necessary. For example:

    PIC S9(7) COMP-3.     Byte size = (7 + 1) / 2 = 4
    
        PIC S9(5)V99 COMP-3.  Byte size = (5 + 2 + 1) / 2 = 4
    
        PIC S9(6) COMP-3.     Byte size = (6 + 1) / 2 = 3.5, rounded to 4

    Comp-3 fields reserve a nybble for the sign, even for "unsigned" values, so the following fields are still 4 bytes:

    PIC 9(7) COMP-3.     Byte size = (7 + 1) / 2 = 4
    
        PIC 9(6) COMP-3.     Byte size = (6 + 1) / 2 = 3.5, rounded to 4

    Examples

    Lets look at some examples of how comp-3 data is stored. The left column in the table below is the decimal value being stored, and the right column is the hexadecimal value you will see in the file:

         Value  Comp-3, hex
           +0           0C
           +1           1C
          +12        01 2C 
         +123        12 3C
        +1234     01 23 4C
           -1           1D
        -1234     01 23 4D
  • 相关阅读:
    git常用指令 github版本回退 reset
    三门问题 概率论
    如何高效的学习高等数学
    数据库6 关系代数(relational algebra) 函数依赖(functional dependency)
    数据库5 索引 动态哈希(Dynamic Hashing)
    数据库4 3层结构(Three Level Architecture) DBA DML DDL DCL DQL
    梦想开始的地方
    java String字符串转对象实体类
    java 生成图片验证码
    java 对象之间相同属性进行赋值
  • 原文地址:https://www.cnblogs.com/kakaisgood/p/13206691.html
Copyright © 2011-2022 走看看