View previous topic :: View next topic
|
Author |
Message |
Pons
New User
Joined: 25 May 2007 Posts: 61 Location: Coimbatore
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forums
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Pons
New User
Joined: 25 May 2007 Posts: 61 Location: Coimbatore
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Aw, gee, you caught me....
Would you belive that I was just testing you.... |
|
Back to top |
|
|
|