Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43657 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42442 invoked from network); 7 Apr 2009 19:34:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Apr 2009 19:34:44 -0000 Authentication-Results: pb1.pair.com header.from=danielc@analysisandsolutions.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=danielc@analysisandsolutions.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain analysisandsolutions.com from 166.84.1.73 cause and error) X-PHP-List-Original-Sender: danielc@analysisandsolutions.com X-Host-Fingerprint: 166.84.1.73 mail2.panix.com Received: from [166.84.1.73] ([166.84.1.73:63803] helo=mail2.panix.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4E/29-28416-3DAABD94 for ; Tue, 07 Apr 2009 15:34:44 -0400 Received: from panix3.panix.com (panix3.panix.com [166.84.1.3]) by mail2.panix.com (Postfix) with ESMTP id 1D1B43480B; Tue, 7 Apr 2009 15:34:41 -0400 (EDT) Received: by panix3.panix.com (Postfix, from userid 14662) id 19CAC8FDDA; Tue, 7 Apr 2009 15:34:40 -0400 (EDT) Date: Tue, 7 Apr 2009 15:34:40 -0400 To: Matt Wilmas Cc: PHP Internals List Message-ID: <20090407193412.GA17502@panix.com> References: <20090402163317.GA25864@panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Subject: Re: [PHP-DEV] [PATCH] double to long conversion change From: danielc@analysisandsolutions.com (Daniel Convissor) Hi Matt, and everyone: On Mon, Apr 06, 2009 at 01:00:47PM -0500, Matt Wilmas wrote: > unless I'm missing something, > you're talking about converting long/int to double/float. That's the > opposite of this thread subject, which is how to convert a double to a > long when it's out of the range of a long. :-) It's a two way street. If the floats don't have enough precision, things get jumbled when converting the floats back to integers. > But, for what you're testing, that's the behavior I'd expect -- once > you've reached the precision of a double, you'll only get the closest > representation possible (and of course a 64-bit long is more precise than > a double since there's no floating point to represent). Also, I assume > what can be represented by a double is the same across platforms, if it's > IEEE 754. Yes. But I was expecting that since long on 64-bit machines holds 64 bits in PHP (et al), that PHP would use C's long double type for floats on 64-bit platforms rather than plain old doubles. It seems like the user-friendly, PHP way to handle the situation, particularly as 64-bit computers are commonplace these days. > Just curious though, you're saying that all whole numbers (from long) > below 2^53 are representable? (Powers of 2 should always be OK.) When > writing a big literal number on a 32-bit system, I'm seeing much lower > than that (around 2^40) I'm talking about 64-bit machines. > Like I said, I figure a double type should > behave the same everywhere. Unless the shell/bash uses a *long* double > type (twice as big as a regular double)? *shrug* Exactly. The test scripts in question are now available for download from http://www.analysisandsolutions.com/php/intfloat/ Thanks, --Dan -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y data intensive web and database programming http://www.AnalysisAndSolutions.com/ 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409