图片带有破折号(-)和X的cobol差异 [英] cobol difference with Picture having a dash (-) and a having a X
问题描述
下面两张图片有什么区别?
What are the differences between the 2 pictures below?
PIC X(15)
PIC- ---,---,-。99。
PIC ----,---,---.99.
底部是代表顶部的另一种方式吗?
Is the bottom just another way to represent the top?
推荐答案
PIC X(15)
表示几乎任何类型的数据的15个字符,可以是
位数字,字母或任何其他符号(可打印或不可打印)。
PIC X(15)
Represents 15 characters of virtually any type of data, could be
digits, letters or any other symbol (printable or not).
PIC ----,-,---。99
表示一个数字编辑的数据项,能够保存+999999999.99至-999999999.99范围内的
值。如果
中的
值为负,则该项目将显示一个负号,否则它将显示没有前导号的数字。如果显示的
数字前面有至少一位数字,则在指定的位置将带有逗号分隔符。
PIC ----,---,---.99
Represents a numeric edited data item capable of holding
values in the range +999999999.99 through -999999999.99. This item will display a leading minus sign if the
value placed into it is negative, otherwise it will display the number without a leading sign. The displayed
number will have comma separators at the indicated positions provided there is at least 1 digit in front of it.
以下是这种方式的一些示例某些数字将显示:
Here are a few samples of the way certain numbers will display:
999999999.99 displays as 999,999,999.99
1234.56 displays as 1,234.56
0 displays as .00
-1234567.12 displays as -1,234,567.12
-3 displays as -3.00
变量此类仅用于显示。甚至不认为
会与他们进行算术运算!给定以下数据声明:
Variables such as this are for display only. Don't even think about doing arithmetic with them! Given the following data declarations:
01 DISP-NBR PIC ----,---,---.99.
01 NBR PIC S9(9)V99.
以下 MOVE
操作均有效
MOVE 1234.56 TO NBR
MOVE 1234.56 TO DISP-NBR
但是,
ADD 1 TO NBR
是完全有效的,但是...
is perfectly valid but...
ADD 1 TO DISP-NBR
会给您一个编译错误。即使 DISP-NBR
包含数字数据,它也只能以
格式显示。您需要使用纯数值数据项进行数学运算,然后 MOVE
将其显示为漂亮打印字段
。
Will give you a compile error. Even though DISP-NBR
contains numeric data it is in a display only
format. You need to do math using data items that are purely numeric and then MOVE
them to display fields
for 'pretty printing'.
这张表
描述了可能在COBOL中使用的所有 PICTURE
元素及其用途。
这篇关于图片带有破折号(-)和X的cobol差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!