Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87380 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50112 invoked from network); 29 Jul 2015 23:35:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jul 2015 23:35:15 -0000 Authentication-Results: pb1.pair.com header.from=derokorian@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=derokorian@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.177 as permitted sender) X-PHP-List-Original-Sender: derokorian@gmail.com X-Host-Fingerprint: 209.85.212.177 mail-wi0-f177.google.com Received: from [209.85.212.177] ([209.85.212.177:33149] helo=mail-wi0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 86/83-25901-23369B55 for ; Wed, 29 Jul 2015 19:35:14 -0400 Received: by wicmv11 with SMTP id mv11so389983wic.0 for ; Wed, 29 Jul 2015 16:35:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=KcBPnzmbK4tEI7R1VRKnA+rCMNiqS3wVWwmNXPUNF3E=; b=f962BOe7jwh+/3pDN6syqKrEI5kffkXyWB1LoXAZhZ3HoETYqwXY/yWuA02xYWz7sV 9GCIlDki8i3n6L8v9qoP1YEzPsyXKx8MOWLENwC0a4KLmr/Va7a+WDhi1gvaiAjPGk3P c4jrA/hiombXNwi8znLm0uiIHivZeVzpPrjIdBHykPXvefLAavZFiblWrxkYeqnjOcL6 Z9ZdE0JXt0TBmAx7DTSQFC1oEzegtdf1AddXjO6C2M8Pw8oYCQf1u/aD76H8uZtc+bgr nk648+bMSHJKpSd+QVYS/HfWTG6veSihTKT3WU0IlGhc0yOPAZ1wJIwSNWrUtHAbU82S k7ow== MIME-Version: 1.0 X-Received: by 10.180.75.15 with SMTP id y15mr317780wiv.51.1438212911016; Wed, 29 Jul 2015 16:35:11 -0700 (PDT) Received: by 10.28.188.70 with HTTP; Wed, 29 Jul 2015 16:35:10 -0700 (PDT) In-Reply-To: References: Date: Wed, 29 Jul 2015 17:35:10 -0600 Message-ID: To: Yasuo Ohgaki Cc: Nikita Popov , Jakub Zelenka , Anthony Ferrara , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=bcaec54fb2c4ac3163051c0c0911 Subject: Re: [PHP-DEV] json_decode/encode should return full precision values by default From: derokorian@gmail.com (Ryan Pallas) --bcaec54fb2c4ac3163051c0c0911 Content-Type: text/plain; charset=UTF-8 On Wed, Jul 29, 2015 at 5:25 PM, Yasuo Ohgaki wrote: > Hi all, > > On Thu, Jul 30, 2015 at 7:44 AM, Yasuo Ohgaki wrote: > > > On Thu, Jul 30, 2015 at 1:13 AM, Nikita Popov > > wrote: > > > >> Instead of continuing to use serialize_precision, which will produce > >> unnecessarily long outputs for many values, why don't we just switch to > >> using the 0 mode of zend_dtoa, i.e. to return the shortest output that > is > >> still accurate if interpreted in round-to-nearest. I think this is what > >> everybody else is using when they convert floating point numbers to > >> strings. I guess we may not be able to change normal floating point > >> printing to use this, but this seems like the best mode for anything > using > >> serialize_precision now and everything that should be using it (like > JSON, > >> and queries, etc). > > > > > > I prefer your proposal! > > Your proposal is a lot better than now. > > Anyone has opinion for this? > > > > I'm writing the RFC and I would like to make this the first option. i.e. > > serialize_precision=0 uses "zend_dtoa 0 mode" for all data exchange > > functions (json/serialize/var_exrport. Anyone care about WDDX/XML_RPC?) > > > > I wrote draft RFC. > > https://wiki.php.net/rfc/precise_float_value > > Please comment. I would like to start RFC discussion shortly. > Thank you. > My thought would be why not -1 to make it obvious it has special meaning? When I see precision=0 I tend to think that means my numbers will be returned as ints no matter what (there is zero fractional precision) whereas this takes a valid value for precision and gives it special meaning. I fully support your end game, but giving a valid value a special meaning I do not like. > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net > --bcaec54fb2c4ac3163051c0c0911--