Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56430 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33418 invoked from network); 19 Nov 2011 13:53:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Nov 2011 13:53:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.170 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.220.170 mail-vx0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:48628] helo=mail-vx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DA/82-17432-AD4B7CE4 for ; Sat, 19 Nov 2011 08:53:31 -0500 Received: by vcbgb30 with SMTP id gb30so366646vcb.29 for ; Sat, 19 Nov 2011 05:53:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=SkjzPupkaL8isZvR0YtlO+nSRK9PiuTSiz3YDg/kvPY=; b=SOfPiSepx2zgISrRpoV7W7CD82ZHjGmK3IOZvVW5isPgH7cJ5SRXMtN4/Y+I+NAEBk 7o6/zRJ/GA7epHBrHcNFO4UrXPmcWA2ZNqnG52i9SnGU7Ub6cWF6HUyUshHdbdeDfLDz 24PBFhkUpjkBFeh+TnaMen/ptcjEbbwtGtyXQ= MIME-Version: 1.0 Received: by 10.224.198.10 with SMTP id em10mr3086576qab.44.1321710807658; Sat, 19 Nov 2011 05:53:27 -0800 (PST) Received: by 10.229.5.84 with HTTP; Sat, 19 Nov 2011 05:53:27 -0800 (PST) In-Reply-To: References: Date: Sat, 19 Nov 2011 08:53:27 -0500 Message-ID: To: Paul Dragoonis Cc: PHP Internals List Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] PHP Integer Bug From: ircmaxell@gmail.com (Anthony Ferrara) If I'm not mistaken, that is to be expected. That's because you're on a 32 bit system, so the maximum possible int (PHP_INT_MAX) is 2147483647. Now, normally PHP could cast to a float to get the larger number in, but you explicitly cast it to an integer, so it had to truncate the value. Try var_dump($s + 0); which correctly results in a float of the correct value. But the problem is that you asked for the int type, which overflowed... Anthony PS: You can use http://codepad.viper-7.com/ to test 5.2, 5.3, 5.4 and Trunk (I believe they do nightly builds of each)... On Sat, Nov 19, 2011 at 8:46 AM, Paul Dragoonis wrote: > Hey guys, > > I don't have a dev environment on my mac here so I can't upgrade to > TRUNK to test so I'm relying on someone on the internals list to test > this. > > ---- PHP INFO ---- > 5.3.1 > > ------ ISSUE ---- > Simple integer work, converting it from being wrapped in a zval.type of string, > into int. Same value would be expected but it's giving an arbitrary value. > > I can't test on latest php 5.3.x as I don't have a dev environment > setup on this > machine. So i'm relying on some mac user to test using trunk and verify. > > ----- OS ---- > MAC OSX 10.7.2 > Darwin Paul-Dragooniss-MacBook-Pro.local 11.2.0 Darwin Kernel Version > 11.2.0: Tue > Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64. > > > ---- CODE --- > $s = "2433078805"; > var_dump($s); > var_dump((int) $s); exit; > > ----- EXPECTED ----- > string(10) "2433078805" int(2433078805) > > ----- ACTUAL ----- > string(10) "2433078805" int(2147483647) > > > Random or what? > > Regards, > Paul Dragoonis. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >