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 Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: How is it work X(5) > X(5) = ?
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

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Jun 01, 2007 12:25 am    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Fri Jun 01, 2007 4:49 am    Post subject: Re: How is it work X(5) > X(5) = ?
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

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Jun 01, 2007 5:56 am    Post subject:
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    Post subject: Re: How is it work X(5) > X(5) = ?
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: 3158
Location: Tucson AZ

PostPosted: Fri Jun 01, 2007 4:47 pm    Post subject:
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    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 Fileaid 2 commands instream work. In ... descann Compuware & Other Tools 2 Tue May 16, 2017 3:31 pm
No new posts What is the maximum number of sort wo... Pravina M SYNCSORT 2 Mon Mar 14, 2016 4:51 pm
No new posts JCL -> Rexx -> XMITIP : Doesnt ... enrico-sorichetti CLIST & REXX 2 Thu Aug 06, 2015 11:09 pm
No new posts Select Variable=string Rexx does not ... Csongor CLIST & REXX 11 Thu May 07, 2015 9:33 pm
No new posts Does FUNCTION NUMVAL work for alphanu... Venkata Ramayya COBOL Programming 8 Fri Mar 20, 2015 10:43 pm


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