Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60549 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81301 invoked from network); 13 May 2012 21:39:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 May 2012 21:39:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 67.192.241.123 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.123 smtp123.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.123] ([67.192.241.123:38170] helo=smtp123.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6B/87-16338-71A20BF4 for ; Sun, 13 May 2012 17:39:35 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp12.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id 3EC743C01E1; Sun, 13 May 2012 17:39:32 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp12.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id CC58A3C0111; Sun, 13 May 2012 17:39:31 -0400 (EDT) Message-ID: <4FB02A13.8090205@sugarcrm.com> Date: Sun, 13 May 2012 14:39:31 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Gustavo Lopes CC: PHP Internals , =?UTF-8?B?Sm9oYW5uZXMgU2NobMO8?= =?UTF-8?B?dGVy?= References: <4FAF1EE5.5010409@sugarcrm.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] bug 54547 From: smalyshev@sugarcrm.com (Stas Malyshev) 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