如何在.net中将数字格式化为S9(5)V99 ascii [英] how to format a number to S9(5)V99 ascii in .net

查看:110
本文介绍了如何在.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

推荐答案

在这里向我们展示的是
图片 COBOL数据声明的子句部分。

What you have shown us here is the PICTURE clause portion of a COBOL data declaration.

COBOL数据声明有点奇怪,需要一些习惯。这是指向 COBOL数据声明
这应该会让您入门。

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.

您在问题中给出的PICture子句定义了具有以下
特征的数字项:

The PICture clause you have given in your question is defining a numeric item with the following characteristics:


  • S -前导符号

  • 9(5)-5个十进制数字

  • V -隐式小数点

  • 99 -隐含小数点后2位数字

  • S - Leading sign
  • 9(5) - 5 decimal digits
  • V - Implied decimal point
  • 99 - 2 digits after the implied decimal point

基本上,您是在告诉COBOL编译器定义一个数字变量,该变量能够将
的值保存为-99999.99至+99999.99。编译器将如何完全满足此
请求,具体取决于特定的 USAGE 子句。但是,对于包含
固定小数位的数字项目,正常用法是 PACKED-DECIMAL COMP-3 (这些只是
的不同名称,意思是同一件事)。此链接
提供了一些有关

Basically, 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 a fixed decimal position, the 'normal' USAGE is PACKED-DECIMAL or COMP-3 (these are just different 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.

将打包的十进制数据写到报告或终端上效果不佳。您必须先将
转换为 DISPLAY able格式。这涉及 MOVE 将打包的十进制值转换为具有 USAGE DISPLAY 属性的另一个
变量。假设您的压缩十进制变量名为
PACKED-DECIMAL-NBR ,并且保留值-2345.01。您可以将显示变量
定义为:

Writing packed decimal data to a report or terminal does not work particularly well. You must first convert it to a DISPLAYable format. This involves MOVEing the packed decimal value to another variable with a USAGE DISPLAY attribute. Suppose your packed decimal variable was called PACKED-DECIMAL-NBR and was holding the value -2345.01. You could define a display variable to hold it as:

01    DISPLAY-NBR     PIC +++,++9.99.

然后是时候编写/显示 PACKED-中包含的值了DECIMAL-NBR 您会
做类似的事情:

then when it comes time to write/display the value contained in PACKED-DECIMAL-NBR you would do something like:

MOVE PACKED-DECIMAL-NBR TO DISPLAY-NBR
DISPLAY DISPLAY-NBR

MOVE 将压缩的十进制数字转换为字符表示,您可以将
显示在报告中或在终端上。显示值 -2,345.01

The MOVE converts the packed-decimal number to a character representation which you can display in reports or on the terminal. The value -2,345.01 is displayed.

这篇关于如何在.net中将数字格式化为S9(5)V99 ascii的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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