Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65742 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19058 invoked from network); 9 Feb 2013 15:47:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Feb 2013 15:47:44 -0000 Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.48 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.215.48 mail-la0-f48.google.com Received: from [209.85.215.48] ([209.85.215.48:59155] helo=mail-la0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 84/DC-18015-E9F66115 for ; Sat, 09 Feb 2013 10:47:43 -0500 Received: by mail-la0-f48.google.com with SMTP id fq13so4600962lab.7 for ; Sat, 09 Feb 2013 07:47:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=n/T7p/mbj5fLF7ywOniWkFhbMYza7A6e4Q4I2iqE2TM=; b=yLvhk+yCWqW/nsF52Ug72QxEYkUPGo+/FDAfTUUonLG3AsFSVemexFnIoxMccQGZEq BPW3fUW1/dqUdL0bw8/U2ioOzskt+zHJ7OfzcYMxbIJulasOm7vD4SIeTU24VL0Q3UZf 6Yy7T2AYshoZN9NHpcKijTmnLHyL2xaGNk+t1NDcvhk7XzWQMETXzMYPPOMQquHkvN+/ MPxJaKCYHnFBTChPm2o1/0ogGuY5yZeHyRuYn2M52NUckVZBiF9qNhts2tU1MCKdY4vS RYmm4Z1hcH8Zpj+03cbVbxSMTzAl7T8Y/RvUvsdY+Df/s2igAOVoy6u7wjcGOo3O8kVS FJNQ== MIME-Version: 1.0 X-Received: by 10.112.43.198 with SMTP id y6mr3674725lbl.93.1360424857996; Sat, 09 Feb 2013 07:47:37 -0800 (PST) Received: by 10.112.111.131 with HTTP; Sat, 9 Feb 2013 07:47:35 -0800 (PST) In-Reply-To: <511666DE.8080809@fedoraproject.org> References: <511666DE.8080809@fedoraproject.org> Date: Sat, 9 Feb 2013 16:47:35 +0100 Message-ID: To: Remi Collet Cc: PHP Internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] double val to long val conversion issue From: pierre.php@gmail.com (Pierre Joye) hi Remi On Sat, Feb 9, 2013 at 4:10 PM, Remi Collet wrote: > About > http://git.php.net/?p=php-src.git;a=commitdiff;h=79956330fe17cfd5f60de456497541b21a89bddf > (For now, I have reverted this fix) > > Here some explanations. > > LONG_MAX is 9223372036854775807 (0x7fffffffffffffff) > double representation of LONG_MAX is 9223372036854775808 > > (d > LONG_MAX) is evaluated in double space. > So is false for double which have the same value than (double)LONG_MAX. > > So, for (double)LONG_MAX the cast used is > (long)d > > 9223372036854775807 on ppc64 > 9223372036854775808 on x86_64 (gcc without optimization) > 9223372036854775807 on x86_64 (gcc -O2) > > PHP expected value is 9223372036854775808 > (Btw, I don't understand why PHP, build on x86_64, with -O2, gives the > good result, some environment mystery) > > Obviously, we could have different result on different platform, > compiler, architecture. > > I will be very interested by result on other platform (mac, windows), > compiler (Visual C), architecture. > > If we switch to the unsigned cast: > (long)(unsigned long)d; > Any comments ? IIRC, on windows/visualC, no matter if it is x86 or x64, long is always 32bits, so it won't change the size of long. Cheers, -- Pierre @pierrejoye