View previous topic :: View next topic
|
Author |
Message |
Dhrubojoty mukherjee
New User
Joined: 23 Mar 2010 Posts: 14 Location: kolkata
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
What do you mean by "type casting"? Give some specific examples. |
|
Back to top |
|
|
Dhrubojoty mukherjee
New User
Joined: 23 Mar 2010 Posts: 14 Location: kolkata
|
|
|
|
Type casting means from numeric to char/alpha numeric or the vice versa.. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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. |
|
Back to top |
|
|
Dhrubojoty mukherjee
New User
Joined: 23 Mar 2010 Posts: 14 Location: kolkata
|
|
|
|
Thanks... |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
|