Re: bug 54547

From: Date: Sun, 13 May 2012 21:39:31 +0000
Subject: Re: bug 54547
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-60549@lists.php.net to get a copy of this message
Hi! > So the float comparison behavior under ~B (what's in the patch) may seem > more desirable because it preserves the numerical comparison when possible > (and we don't have to add leading whitespace and zeros to the mix, > strcmp("9, "11") returns 1). Until you realize it's alternating between > two behaviors depending on whether B or ~B. So: > > "9223372036854775809" < " 09443372036854775809" (true, -- floats differ, > > compare as float) > "9223372036854775809" < " 09223372036854775810" (false -- floats are the > > same, memcmp) I understand this may not be ideal but I really see this as very narrow use case - if you really want to compare strings in lexicographical order, you just should use strcmp. So I think this fixes common cases where people have high WTF factor, and if we later have better idea on how to fix all the cases we could amend it further. But I'm not sure adding more magic to the mix (i.e. doing special comparisons, etc.) is going to be better - it will only make it harder for people to understand. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227

« previous php.internals (#60549) next »