Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to format a number to S9(5)V99 ascii in .net

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

like image 287
user392973 Avatar asked Jul 15 '10 16:07

user392973


People also ask

What does S9 (6) V99 mean in Java?

So s9(6)V99is a signed number with 6 digits before the decimal place + 2 after Effect of Encoding The encoding(characterset) used by the server determines how the sign digit is represented. For US (and UK) Ebcdic +0/-0 are { / }but they are different for German Ebcdic. For ASCII servers it is different again Java Code

Is S9(5)V99 a positive or negative number?

If it were a "+" that had been overpunched, then it would be a positive number. 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?

What is the Pic -99 format?

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 a PIC S9 (5)V99 field might reasonably be moved to a PIC -99,999.00 field.

What is the S9 (6) V99 format exmaples of COBOL?

COBOL s9(6)V99 format exmaples: 0000016H 0000000{ Note: Currently I have no implementation of the conversion,I am looking for a solution javaparsingcobol


1 Answers

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 sign
  • 9(5) - 5 decimal digits
  • V - Implied decimal point
  • 99 - 2 digits after the implied decimal point

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.

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.

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

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.

like image 76
NealB Avatar answered Oct 01 '22 19:10

NealB