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

comparing comp-3 and unpacked numbers


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

New User


Joined: 04 May 2012
Posts: 34
Location: Brazil

PostPosted: Mon May 30, 2016 6:46 pm
Reply with quote

Hi everyone!
Is the comparison between COMP-3 numbers against unpacked numbers OK?
I mean, if We have, for example:
a-field 9(5) COMP-3 and
b-field 9(5)

Could We compare easily: IF a-field = b-field ...
without move one of them to the same PIC of compared field in Cobol program?

Thanks in advance.
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 May 30, 2016 7:05 pm
Reply with quote

Have you read the Enterprise COBOL Language Reference manual on numeric comparisons? If not, why not -- it has almost all the answers you could possibly want on how COBOL works on the mainframe. If you did read that, did you not see this on page 272 of the version 6.1 COBOL manual (emphasis added by me):
Quote:
Numeric comparisons
A numeric comparison is a comparison of the algebraic value of two operands of
class numeric.
When the algebraic values of numeric operands are compared:
v The length (number of digits) of the operands is not significant.
v The usage of the operands is not significant.

v Unsigned numeric operands are considered positive.
v All zero values compare equal; the presence or absence of a sign does not affect
the result.
The behavior of numeric comparisons depends on the settings of the NUMPROC
and ZONEDATA compiler options. For details,
Back to top
View user's profile Send private message
juares castro

New User


Joined: 04 May 2012
Posts: 34
Location: Brazil

PostPosted: Tue May 31, 2016 6:30 am
Reply with quote

Thanks a lot Robert!
I will read COBOL Language Reference manual as You said.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Wed Jun 01, 2016 2:25 am
Reply with quote

Why not try and learn and that's quicker than anything unless you need a rapid answer for an interview question? icon_smile.gif
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Generate random number from range of ... COBOL Programming 3
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
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