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

Compare between a numeric (9(8)) and packed decimal(s9(9)


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

New User


Joined: 23 Mar 2010
Posts: 14
Location: kolkata

PostPosted: Mon Aug 11, 2014 2:41 pm
Reply with quote

Is it possible to compare between a numeric (9(8)) and packed decimal(s9(9) comp-3) field in cobol with out any type casting?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Aug 11, 2014 2:55 pm
Reply with quote

What do you mean by "type casting"? Give some specific examples.
Back to top
View user's profile Send private message
Dhrubojoty mukherjee

New User


Joined: 23 Mar 2010
Posts: 14
Location: kolkata

PostPosted: Mon Aug 11, 2014 4:07 pm
Reply with quote

Type casting means from numeric to char/alpha numeric or the vice versa..
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon Aug 11, 2014 4:48 pm
Reply with quote

You can compare the two. However, keep in mind that if the COMP-3 field exceeds 99999999 (max value of the 8-byte display-numeric field), your compare may not work as expected.

The compiler will "PACK" the 8-byte display-numeric field into a COMP-3 work-field and a "Compare Decimal/Pack" (CP) instruction will be issued.

This is basic knowledge for any s.e. icon_eek.gif
Back to top
View user's profile Send private message
Dhrubojoty mukherjee

New User


Joined: 23 Mar 2010
Posts: 14
Location: kolkata

PostPosted: Mon Aug 11, 2014 5:23 pm
Reply with quote

Thanks...
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Aug 11, 2014 6:09 pm
Reply with quote

Dhrubojoty mukherjee wrote:
Type casting means from numeric to char/alpha numeric or the vice versa..


Well if that's what it means (to you) then the question is moot in this case, is there is no "char/alpha numeric" involved.

The compare will not be a problem as is. Try it.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Aug 11, 2014 7:03 pm
Reply with quote

If you have not yet found it, the Enterprise COBOL Language Reference manual at publibfp.boulder.ibm.com/epubs/pdf/igy5lr11.pdf has a table of valid and invalid elementary variable moves (on pages 373 - 374 of the version 5.1 manual) under the MOVE statement discussion. This table tells you which moves are allowed in COBOL and should be consulted first -- if you had done so, you would have had your answer much earlier than through posting on this forum.

Also, COBOL does not use "type casting" as such -- the table of valid moves indicates any conversions that will be done.
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

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
Search our Forums:

Back to Top