Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Compare between a numeric (9(8)) and packed decimal(s9(9)

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Compare between a numeric (9(8)) and packed decimal(s9(9)
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Mon Aug 11, 2014 2:55 pm    Post subject: Reply to: Compare between a numeric (9(8)) and packed decima
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    Post subject: Reply to: Compare between a numeric (9(8)) and packed decima
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: 2504
Location: Atlanta, Georgia, USA

PostPosted: Mon Aug 11, 2014 4:48 pm    Post subject: Reply to: Compare between a numeric (9(8)) and packed decima
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    Post subject:
Reply with quote

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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Mon Aug 11, 2014 6:09 pm    Post subject: Re: Reply to: Compare between a numeric (9(8)) and packed de
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: 8151
Location: East Dubuque, Illinois, USA

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

If you have not yet found it, the Enterprise COBOL Language Reference manual at http://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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts Return a Non Numeric value from REXX Learncoholic CLIST & REXX 3 Fri Sep 01, 2017 8:33 pm
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am
No new posts Validate if a Value from the file is ... balacsv2 COBOL Programming 8 Mon Jun 19, 2017 11:52 pm
No new posts compare 2 rows within the same file ram_vizag SYNCSORT 7 Wed Jun 14, 2017 12:34 am

Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us