Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42919 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74170 invoked from network); 4 Feb 2009 17:32:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2009 17:32:07 -0000 Authentication-Results: pb1.pair.com header.from=php_lists@realplain.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php_lists@realplain.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain realplain.com from 209.151.69.1 cause and error) X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 209.151.69.1 liberty.vosn.net Linux 2.4/2.6 Received: from [209.151.69.1] ([209.151.69.1:40788] helo=liberty.vosn.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/36-61634-511D9894 for ; Wed, 04 Feb 2009 12:32:05 -0500 Received: from 72-161-140-28.dyn.centurytel.net ([72.161.140.28]:54911 helo=PC) by liberty.vosn.net with smtp (Exim 4.69) (envelope-from ) id 1LUlbW-00028S-7Q; Wed, 04 Feb 2009 10:32:02 -0700 Message-ID: <00fd01c986ee$7d94ec20$0201a8c0@PC> To: , "Iain Lewis" References: Date: Wed, 4 Feb 2009 11:30:53 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1933 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1933 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - liberty.vosn.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - realplain.com Subject: Re: [PHP-DEV] casting doubles to ints From: php_lists@realplain.com ("Matt Wilmas") Hi Iain, (Yes, this subject has me sending a message to the list again instead of lurking, and I should be back with some internals stuff again soon, hehe. :^)) ----- Original Message ----- From: "Iain Lewis" Sent: Wednesday, February 04, 2009 Subject: [PHP-DEV] casting doubles to ints > Hello all, > > I wanted to suggest back porting the behaviour of the DVAL_TO_LVAL macro > from zend_operators.h from 5.3 to 5.2, and wondered whether people > thought this was a good idea or not? > > The reason I want to do this is that while writing some tests, I noticed > that the behaviour of casting a float to an int is a bit > counter-intuitive on 64bit platforms for PHP 5.2. It looks as though > this has been fixed in 5.3, and it would seem like a good idea to put > this change back to 5.2 as well. From a personal point of view, it would > mean I could write one test that would work on both 5.2 and 5.3, but it > also seems like a sensible change, as the current behaviour is > non-obvious. The change would cause some current tests to break, but I > am happy to do the work to fix those up. NOOOO, please. :-) In fact, I thought maybe your message was complaining about the 5.3 changes. I was suggesting reverting 5.3 to 5.2's behavior at the very least -- see my "DVAL_TO_LVAL() change, different behavior" thread [1] from last year for the reasons. It breaks long-time behavior (overflow-wise), and isn't even consistent with how it works. I was thinking there will be some breakage, bug reports, etc. as 5.3 is used more, if others are doing stuff like my examples showed. *shrug* In addition to my suggestion of going back to the behavior of 5.2 and earlier, I think DVAL_TO_LVAL() can be updated to ensure consistent, reliable overflow behavior on all systems -- it seems like it has been on the majority, but a simple (long) cast of the double (when out of range) in C is implementation-defined, so depending... Anyway, I didn't get to test my idea yet, but will get to it soon! The thing that I think was originally trying to be fixed (large function args) can be done easily in zend_parse_parameters() for those desired use cases. [1] http://marc.info/?t=120799728700001&r=1&w=2 > This is how a few expressions get evaluated at the moment. Changing the > macro would make the 5.2 behaviour match 5.3 > > Expression 5.3 (RHEL5-64) 5.2 (RHEL5-64) > > (int) (PHP_INT_MAX) 9223372036854775807 9223372036854775807 > (int) (PHP_INT_MAX + 1) 9223372036854775807 -9223372036854775808 > (int) (PHP_INT_MAX + 1000) 9223372036854775807 -9223372036854775808 > (int) (PHP_INT_MAX + 10000) 9223372036854775807 -9223372036854765568 > > Does this seem like a good change? - Matt