View previous topic :: View next topic
|
Author |
Message |
Naresh Ch
New User
Joined: 16 Jan 2009 Posts: 2 Location: India
|
|
|
|
Hi All,
I work in an application that is around 5 years old. While debugging a program to solve a prod error, I have come across a data type like
-10(9).99.
The error was that the variable with the above mentioned data type doesnt accept positive values and its size was 14 bytes. When I removed the negative sign it was accepting both positive and negative values but the size became 4 bytes(I saw the variable sizes through expeditor)
Can anyone tell me what this declaration means and also the significance of the negative sign |
|
Back to top |
|
|
leo_sangha
New User
Joined: 11 Aug 2005 Posts: 85 Location: England
|
|
|
|
5 yrs old Mainframe application is pretty new i would say.
Please post the complete declaration of the variable.
Also post the snapshot that you saw through expeditor. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Quote: |
a data type like -10(9).99. |
Like?
As in maybe it was -9(10).99?
Or something else?
I can see 0(9) works but I don't see how the '1' works..... |
|
Back to top |
|
|
Naresh Ch
New User
Joined: 16 Jan 2009 Posts: 2 Location: India
|
|
|
|
The declaration looks like this..
05 WT-TOT-PRM-L1 PIC -(10)9.99 VALUE ZERO. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
One of the reasons it is so important to cut and paste from the actual code is when you paraphrase, you get it wrong.
Quote: |
I have come across a data type like -10(9).99. |
-(10)9.99 makes sense, or -9(10).99 -- but you paraphrased it wrong.
Quote: |
The error was that the variable with the above mentioned data type doesnt accept positive values |
This is nonsense -- you misunderstand what COBOL is telling you, or you don't know enough COBOL to realize that your statement is wrong.
To wit:
Code: |
WORKING-STORAGE SECTION.
01 WS-A1 PIC -(10)9.99.
01 WS-B1 PIC -(10)9.99.
/
PROCEDURE DIVISION.
S1000-MAIN SECTION.
MOVE -12345.67 TO WS-A1.
MOVE 12345.67 TO WS-B1.
DISPLAY 'WS-A1: ' WS-A1.
DISPLAY 'WS-B1: ' WS-B1. |
produces output of
Code: |
WS-A1: -12345.67
WS-B1: 12345.67 |
which very clearly proves that a -(10)9.99 field will accept a positive value. The negative sign is printed if and only if the value is negative -- otherwise a space is printed. The -(10)9.99 indicates there are 11 characters in front of the decimal point and 2 characters after the decimal point. If the value is negative, the negative sign will appear just before the first significant digit. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
... all of which is explained in glorious detail in the COBOL Language Reference manual. |
|
Back to top |
|
|
|