IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Comparing COMP-3 and Invalid decimal


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Aug 08, 2007 8:14 pm
Reply with quote

Quote:
how can an invalid numeric be equals to COMP-3 zeroes.


I told you before, if you use PIC 9 DISPLAY, COBOL treats you like an idiot and will allow just about anything to happen. That is why you need to qualify any computation or compare with a numeric display field with a preceding IS NUMERIC. Now, had the array been composed of decimal definitions (COMP-3) then you would not have any problems.

until you combine the compare with the IS NUMERIC, you do not have invalid numerics.

RTFM!!!!!
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Wed Aug 08, 2007 8:23 pm
Reply with quote

Hi Scherrer,

PAYEE-ID-NO is a comp-3 field, But in my shop when I display comp-3 field in spool it will be displayed in a readable format.

I am using IOF not SDSF.

Now what I understand is because COBOL treated me as an idiot it went it's on way and gave an undesirable and unpredictable result. Great icon_surprised.gif

Thanks,
Abin.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Aug 08, 2007 8:44 pm
Reply with quote

Quote:

Now what I understand is because COBOL treated me as an idiot it went it's on way and gave an undesirable and unpredictable result. Great


abin,

The behavior of the machine is predictable. You just have to read the manuals (or in this case, learn from experience). PIC 9 DISPLAY is well documented. Unless you qualify with IS NUMERIC, PIC 9 DISPLAY fields will do what ever you tell them to, regardless of their content, because they are not bound by the rules governing truly numeric definitions.

you are feeling foolish because you made an assumption, don't continue making assumptions.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Aug 08, 2007 10:26 pm
Reply with quote

Hello Abin,

If you have the time and the inclination, change the value in the array to ALL x'00's (getting rid of the x'F0' at the end). Your results will not be the same. Again, if you want to see more of exactly what happened, take a look at the assembler code that was generated to do the compare.

Quote:
PAYEE-ID-NO is a comp-3 field
Only by definition - not by content. A comp-3 field must contain
Code:

ddddd
dddds
where the d's are digits that must be zero thru nine and the s must be a valid sign.

As DBZ points out, there is a wealth of material in the manuals (which are avaliable via the "Manuals" link at the top of the web page).
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Fri Aug 10, 2007 9:46 am
Reply with quote

Hi,

Sorry for being late to reply. I am stuck in another important work. I'll do as you suggetsted and let you know of the results.

Thanks for all the support.
Abin.
Back to top
View user's profile Send private message
chiranjeevi_mca

New User


Joined: 19 Feb 2006
Posts: 27

PostPosted: Tue Aug 21, 2007 10:48 am
Reply with quote

Hi,

if we initialized the numeric values, the data-item contains ZEROs. if that may be a Numeric,COMP,COMP-1,COMP-2,COMP-3.

the data internally process in a binary format.

Ex: PIC 9(10) is decimal. if we want to process this, first it will convert from decimal to binary(internally). it takes time to convert, to avoid this we use COMP. Comp internally stores in a binary format, that's why we cann't display this values directly in the console.

If we declare the data-items in numeric. there is no way to store the ???
the stored values in numeric are NUMERIC (0-9), HIGH-VALUES, LOW-VALUES.
Back to top
View user's profile Send private message
Saroj Tripathy

New User


Joined: 05 Mar 2007
Posts: 23
Location: India

PostPosted: Mon Aug 27, 2007 12:10 pm
Reply with quote

Hi while going thru the mails I found abin mentioning the below

Quote:
The first entry in the table has some undefined value LOW-VALUE or HIGH-VALUE. Whatever, it is a value that should not be there in a decimal field. My doubt how is an invalid decimal equals to COMP-3 zeroes. Please clarrify whether this is possible or not.




Now can it be that LOW-VALUE is same as zeroes and hence the match ???
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Comparing Header and Trailer. DFSORT/ICETOOL 7
Search our Forums:

Back to Top