Strings when they are compared with each other it happens at the character level i.e character by character comparision, when two strings are of unequal size then is the smaller string padded to make it equal with the longer string, if yes then with which character is it padded with?
Ex 'abcd'<'efghts'
In the above example does the single relational expressions becomes multiple expressions involving one character each time? "a<e", "b<f".....
If so then how is the final value decided, is it based on majority?
or is my understanding completely wrong please enlighten.....
Thanks
String Comparision
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 730
- Joined: Tue Nov 04, 2008 10:14 am
- Location: Bangalore
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You're almost there. Strings are compared character by character. If, when the end of the shorter string is encountered, no difference has been found, then the shorter string is "less than" the longer string.
No padding occurs.
No padding occurs.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 730
- Joined: Tue Nov 04, 2008 10:14 am
- Location: Bangalore
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
The comparison is character-by-character. Therefore as soon as one character in the shorter string is "greater than" the corresponding character in the other string, previous characters having matched exactly, then the shorter string is "greater than" the longer. For example, "WOLF" is greater than "AARDVARK", "Grease mop" is greater than "Grease ball". If you want to compare the lengths, then compare the lengths. Use the Len() function.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.