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

How is it work X(5) > X(5) = ?


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

New User


Joined: 25 May 2007
Posts: 61
Location: Coimbatore

PostPosted: Thu May 31, 2007 11:04 pm
Reply with quote

Hi,

I have an variable declaring like,

05 TERR-CD1 PIC X05) VALUE '100'.
05 TERR-CD2 PIC X05) VALUE '200'.

I JUST TRY TO COMPARE THIS ALPHA NUMERIC VARIABLES,

IF TERR-CD1 > TERR-CD2
DISPLAY 'A > B'
ELSE
DISPLAY 'B > A'
END-IF.

IT'S WORKING FINE. I GAVE THE RESULT AS B > A

I JUST WANT TO KNOW, HOW IT IS COMPARING ALPHA NUMERIC, WITH OUT CONVERTING IT INTO NUMERIC. IS THIS ALPHA NUMERIC COMPARE ALWAYS WORKING CORRECTLY OR ANY CONSTRAINT IS THERE?
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: Fri Jun 01, 2007 12:25 am
Reply with quote

Hello and welcome to the forums icon_smile.gif

You defined character fields and the system did a character compare. There is no numeric involved.

If you want to do numeric compares, you must tell the system you want to work with numbers rather than characters.

If that is not clear, please let us know.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jun 01, 2007 4:49 am
Reply with quote

Pons wrote:
I JUST WANT TO KNOW, HOW IT IS COMPARING ALPHA NUMERIC, WITH OUT CONVERTING IT INTO NUMERIC. IS THIS ALPHA NUMERIC COMPARE ALWAYS WORKING CORRECTLY OR ANY CONSTRAINT IS THERE?
TURN OFF YOUR CAPS_LOCK!!!!!!!
With the PIC of X(5), you are dealing with eight bit data.
X'4040F1F0F0' and
X'4040F2F0F0'.......which translate from hex to binary as
01000100111100011111000011110000 and
01000100111100101111000011110000 and as yoy can see, the 15th position in the binary field is greater the the other.....
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: Fri Jun 01, 2007 5:56 am
Reply with quote

Hello Pons,

Do you have an answer for your question?

I believe we've explained what happened, but i'm not sure that is your complete question.

Please let us know if you'd like additional info.
Back to top
View user's profile Send private message
Pons

New User


Joined: 25 May 2007
Posts: 61
Location: Coimbatore

PostPosted: Fri Jun 01, 2007 2:30 pm
Reply with quote

Hi,

Thanks for your clarifications. I got my answer. William Thompson explained with hex decimal and binary.

But one more doubt. Normally the characters are storing form the left to right i guss. But William, you mentioned as

X'4040F1F0F0'
spsp1 0 0
X'4040F2F0F0'
spsp2 0 0

Is it storing in the above format or its like,

X'F1F0F04040'
1 0 0 spsp
X'F2F0F04040'
2 0 0 spsp

Please let me know.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jun 01, 2007 4:47 pm
Reply with quote

Aw, gee, you caught me.... icon_redface.gif
Would you belive that I was just testing you.... icon_rolleyes.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 isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts Negative value - packed field - Natur... Java & MQSeries 0
No new posts TWS - ETT File triggering does not wo... IBM Tools 4
No new posts SAS Work space - B37 abend JCL & VSAM 15
No new posts IBM Pcomm macro startmacro command do... IBM Tools 0
Search our Forums:

Back to Top