Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87385 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81851 invoked from network); 30 Jul 2015 09:06:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jul 2015 09:06:53 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@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: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.212.177 mail-wi0-f177.google.com Received: from [209.85.212.177] ([209.85.212.177:35146] helo=mail-wi0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/D6-25901-C29E9B55 for ; Thu, 30 Jul 2015 05:06:52 -0400 Received: by wibxm9 with SMTP id xm9so235148637wib.0 for ; Thu, 30 Jul 2015 02:06:48 -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=KonSpoMOHnLDcLmTGL4rztYzVk0nd2KXnG6O5cWw/E0=; b=lEPbjbTl3tXr1lmn+cMEjapX88NHRa4rvHoqteYHpW0t3Bob4jKQM0NsOmSJPGmnD9 QzIjG1hj3/xprw0YApG9DpiHN0hzvCtbN3UU3YufVQTELPpvVdzXktMHLr5nU5KxSHEm aqxE0KUkpDCfQnrPTObWGZxXKWfjtBWdzcaeLV7+w2rJoTETPl3PEIq/PpJ+HXjc9Yv4 WOVRKZ9PDQRn+w3eCEDmfrLOiG+nO9o6azNqsf9Ok850WksbYZMRCFoJco7wrSxxNZmN aQeog9uhQ5bSMfjRa+fGwljUcWOsdrjfPkPuaZt58wGfjS8P66n2vJI8vF9zD0srlxNh SDvg== MIME-Version: 1.0 X-Received: by 10.180.91.134 with SMTP id ce6mr4399698wib.60.1438247208844; Thu, 30 Jul 2015 02:06:48 -0700 (PDT) Received: by 10.27.3.85 with HTTP; Thu, 30 Jul 2015 02:06:48 -0700 (PDT) In-Reply-To: References: Date: Thu, 30 Jul 2015 11:06:48 +0200 Message-ID: To: Yasuo Ohgaki Cc: Jakub Zelenka , Anthony Ferrara , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=f46d043c7ec4fb8180051c140500 Subject: Re: [PHP-DEV] json_decode/encode should return full precision values by default From: nikita.ppv@gmail.com (Nikita Popov) --f46d043c7ec4fb8180051c140500 Content-Type: text/plain; charset=UTF-8 On Thu, Jul 30, 2015 at 1:25 AM, 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. > Nice idea about using a special serialize_precision value for this. This allows to keep BC for those that have tests for particular serialize output or similar things. I would suggest to default serialize_precision to -1 in PHP 7 -- if people want the previous behavior they can still have it, but I think -1 is the more reasonable default as it matches what one would naturally expect. I don't see the need for having a separate setting for JSON. Having a dozen different float precision settings will not help anyone. Nikita --f46d043c7ec4fb8180051c140500--