Re: When is "z" != "z" ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tedd wrote:
At 12:27 PM -0700 6/4/06, Rasmus Lerdorf wrote:
tedd wrote:
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"

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.

Of course it is.

php -r 'echo "aaa" < "z";'
1

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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux