Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32862 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91703 invoked by uid 1010); 18 Oct 2007 20:02:25 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 91688 invoked from network); 18 Oct 2007 20:02:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Oct 2007 20:02:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=rrichards@ctindustries.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rrichards@ctindustries.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain ctindustries.net from 216.117.147.250 cause and error) X-PHP-List-Original-Sender: rrichards@ctindustries.net X-Host-Fingerprint: 216.117.147.250 unknown Received: from [216.117.147.250] ([216.117.147.250:55099] helo=ctindustries.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0F/66-61918-DCBB7174 for ; Thu, 18 Oct 2007 16:02:23 -0400 Received: from [127.0.0.1] ([67.158.171.203]) (authenticated bits=0) by ctindustries.net (8.13.8/8.13.8) with ESMTP id l9IJt6SM030128; Thu, 18 Oct 2007 15:55:16 -0400 Message-ID: <4717BB8C.5050404@ctindustries.net> Date: Thu, 18 Oct 2007 16:01:16 -0400 User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Stanislav Malyshev CC: internals@lists.php.net References: <470D0DD8.7080100@ctindustries.net> <47169656.9090708@zend.com> In-Reply-To: <47169656.9090708@zend.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 000782-1, 10/17/2007), Outbound message X-Antivirus-Status: Clean X-Virus-Scanned: ClamAV 0.91.2/4545/Wed Oct 17 17:05:57 2007 on ctindustries.net X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=4.4 tests=AWL autolearn=disabled version=3.1.9 X-Spam-Checker-Version: SpamAssassin 3.1.9 (2007-02-13) on ctindustries.net Subject: Re: [PHP-DEV] Object arithmetic From: rrichards@ctindustries.net (Rob Richards) Stanislav Malyshev wrote: >> While looking at bug 42780: http://bugs.php.net/bug.php?id=42780 >> The only way not to lose precision is to explicitly cast the object >> to float or string, which just doesn't seem right to me. > > I'm not sure how this can be fixed - there should be some type used > and many objects won't provide convertor to float... Anyway, it's > probably not the best idea to rely on default conversion in this > context - better to specify it. I would have agreed 100% that explicit casting should be used, but with to_string around, it just doesn't seem right now.Take the following: $xml = '1.12.2'; $sxe = simplexml_load_string($xml); print $sxe->a ." + ".$sxe->b." = ".($sxe->a +$sxe->b); 1.1 + 2.2 = 3 And why wouldn't objects provide a float converter? If they provided a converter to long why wouldn't they also provide means to convert to float. Rob