如何在.net中将数字格式化为S9(5)V99 ascii
我一直在寻找 s9(5)v99 但得到了不同的信息,而且不太清楚。有人可以展示如何转换或转换公式吗?谢谢
I've been searching for s9(5)v99 but got different information and not really clear. Could someone shows how or the formula to convert. thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您在这里向我们展示的是
COBOL 数据声明的 PICTURE 子句部分。
COBOL 数据声明有点奇怪,需要一些时间来适应。这是一个介绍性的链接
关于COBOL 数据声明的教程。
这应该可以帮助您开始。
您在问题中给出的 PICture 子句正在使用以下内容定义一个数字项
特征:
S
- 前导符号9(5)
- 5 个小数位V
- 隐含小数点99
- 2隐含小数点后的数字基本上,您是在告诉 COBOL 编译器定义一个能够保存
值 -99999.99 到 +99999.99。编译器将如何实现这一点
请求取决于特定的
USAGE
子句。但是,对于包含固定小数位,“正常”用法是
PACKED-DECIMAL
或COMP-3
(这些只是不同的名称表示相同的意思)。此链接
提供一些有关打包十进制数据的存储表示的介绍性信息。
压缩十进制数据对于进行小数点位数必须进行的数值计算非常有用
保持固定。
将压缩十进制数据写入报表或终端效果不是特别好。你必须
首先将其转换为可显示的格式。这涉及将压缩的十进制值
MOVE
移动到另一个具有
USAGE DISPLAY
属性的变量。假设你的压缩十进制变量被称为PACKED-DECIMAL-NBR
并保存值 -2345.01。您可以定义一个显示变量将其保存为:
那么当需要写入/显示
PACKED-DECIMAL-NBR
中包含的值时,您会执行以下操作:
MOVE
将压缩十进制数转换为字符表示形式,您可以显示在报告或终端上。显示值
-2,345.01
。What you have shown us here is
the
PICTURE
clause portion of a COBOL data declaration.COBOL data declarations are a bit odd and take some getting used to. Here is a link to an introductory
tutorial on COBOL data declarations.
This should get you started.
The PICture clause you have given in your question is defining a numeric item with the following
characteristics:
S
- Leading sign9(5)
- 5 decimal digitsV
- Implied decimal point99
- 2 digits after the implied decimal pointBasically, you are telling the COBOL compiler to define a numeric variable capable of holding
the values -99999.99 through +99999.99. Exactly how the compiler will fulfill this
request depends on the specific
USAGE
clause. However, for numeric items containing afixed decimal position, the 'normal' USAGE is
PACKED-DECIMAL
orCOMP-3
(these are justdifferent names meaning the same thing). This link
provides some introductory information concerning the storage representation of packed decimal data.
Packed decimal data are useful for doing numeric computations where the number of decimal points must
remain fixed.
Writing packed decimal data to a report or terminal does not work particularly well. You must
first convert it to a
DISPLAY
able format. This involvesMOVE
ing the packed decimal value to anothervariable with a
USAGE DISPLAY
attribute. Suppose your packed decimal variable was calledPACKED-DECIMAL-NBR
and was holding the value -2345.01. You could define a display variableto hold it as:
then when it comes time to write/display the value contained in
PACKED-DECIMAL-NBR
you woulddo something like:
The
MOVE
converts the packed-decimal number to a character representation which you candisplay in reports or on the terminal. The value
-2,345.01
is displayed.cobol中的S是有符号数字字段的定义(即可以是正数或负数)。
例如,S999 是一个有符号的 3 位数字(二进制)。问题是假设 S ,并且在大多数 cobol 编译器中,标记符号的方式是用另一个字符“过度打孔”最后一个字符来表示加号或减号。结果,如果您在 ascii 浏览器中查看该字段,您将看到一个奇怪的字符。 IE。 MINUS 500 看起来像 50C 或 50},具体取决于底层字符以及是否是过度打孔的 + 或 -。
S in cobol is the definition of a signed numeric field (ie can be positive or negative).
So for example S999 is a signed 3 digit numeric (binary). Problem is S is assumed, and in most cobol compilers, the way the sign is marked is by "overpunching" the last character with another character to signify plus or minus. This results, if you look at the field in an ascii browser, you will have a strange character. Ie. MINUS 500 would look something like this 50C or 50} depending on the underlying character and if it were a + or - that had overpunched.
PIC S9(5)v99
不是数字格式。它描述了数据的存储方式及其含义。例如,存储为“-0010000”的数字表示-100.00。您究竟想实现什么目标?您是否正在尝试将
十进制
-100.00 发送到COBOL 程序?PIC -99,999.00
是数字格式。它指定如果数字为负数,则使用前导减号,使用小数点前五位数字,在千位之间使用逗号,小数点,然后正好两位数。存储在PIC S9(5)V99
字段中的数字可以合理地移动到PIC -99,999.00
字段。PIC S9(5)v99
isn't a number format. It's a description of how the data are stored and what it means there. For instance, a number stored as "-0010000" means -100.00.What exactly are you trying to accomplish? Are you trying to send a
decimal
-100.00 to a COBOL program?PIC -99,999.00
is a number format. It specifies to use a leading minus sign if the number is negative, to use five digits before the decimal place, with a comma between the thousands, a decimal point, then exactly two digits after. A number stored in aPIC S9(5)V99
field might reasonably be moved to aPIC -99,999.00
field.公共函数 CobolToDec(ByVal str As String) 作为双
端函数
Public Function CobolToDec(ByVal str As String) As Double
End Function