Re: When is "z" != "z" ?
| From: | Rasmus Lerdorf | Date: | Sun, 04 Jun 2006 20:09:05 +0000 |
| Subject: | Re: When is "z" != "z" ? | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-237375@lists.php.net to get a copy of this message | ||
tedd wrote:
At 12:27 PM -0700 6/4/06, Rasmus Lerdorf wrote:Of course it is. php -r 'echo "aaa" < "z";' 1tedd wrote:I agree with [1] and [2], but [3] is where we part company. You see, if you are right, then "aaa" would also be less than "z", but that doesn't appear so.But, what brothers me about the routine, is that is DOES print "z" where it is supposed to. In other words, the characters a-z are output before continuing with aa and so on. The operation doesn't end with "z".Your condition for the loop to continue is $i<="z". [1] When $i = "y" it will obviously continue because "y" < "z" [2] When $i = "z" it will obviously continue because "z" = "z" [3] When $i = "aa" it will obviously continue because "aa" < "z"
Not meaning to infer that you don't know this, because I know you do -- so I must be confused. Yes, it is my contention that strings are numerical -- you don't store "A" in memory, you store 0100 001, or ASCII DEC 65. Likewise "a" is DEC 97 (0110 0001) and "z" is DEC 122 (0111 1010) and if I compare "a" to "z" , it will always be less by numeric definition. However, if I compare "aa" with "z", then what? Is the numerical translation of the strings -- 0110 0001 0110 0001 < 0111 1010 equal to TRUE -- I don't think so.No, but we are talking about collation here, not representation.
Likewise, is the string "aaa"" greater than "z" -- yep, I can buy that.Well, it isn't. So the bulk of your rant is rather meaningless. -Rasmus