Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93635 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93373 invoked from network); 30 May 2016 18:28:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 May 2016 18:28:27 -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.161.178 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.161.178 mail-yw0-f178.google.com Received: from [209.85.161.178] ([209.85.161.178:35605] helo=mail-yw0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/10-26200-A468C475 for ; Mon, 30 May 2016 14:28:26 -0400 Received: by mail-yw0-f178.google.com with SMTP id o16so168670086ywd.2 for ; Mon, 30 May 2016 11:28:26 -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; bh=/z1jmmEUhF+CNR2mpqYLQXSSm99YYVICTN5A7phLho0=; b=UMlJpdWPwtXAMgnDmw89cCXh3L/aL+JgYhGF7Rnh0EmzcjxIBfbUg2TNUJyfLOLlng 72TuseTczT/8gS2c9OqeHodztS4ZbcKVwkL2jj4/uvandSNjWaZsje34q9SzhmGQh9i1 ghdxA77vKn/uMiYMoGrgCZFpz64b+XtlkTFAvRo/S4i9x4gTpXSdmFyAINtgLGmrM3cl xKna/rSKwmmJwrJ1zkUd4HqTVRxOg7G+vUXc1V93RbwJP7idEj59C0qW5azo2w/m5mW2 KAryzMGhy2GceIcae3E1ZVQVAsY8WHnchhP+c+wx3H9P+JlKliaeOZ9xSgazJThULt4v ExGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=/z1jmmEUhF+CNR2mpqYLQXSSm99YYVICTN5A7phLho0=; b=VZlg0C4+r5zJxU7Ox6e04T+ef9kmlIe3navmn5Rz8q7B+W9769XpfQqQELUWbJ+p/Y 4/sNf64a4vkl4LZY7R4HavW7RYuD+sPwkKZaLdbmZHnxb8IeQ+Ngv/to8VwyfpK3gPnz 8upqWMcH22GPDSRUOtotOc6usM/1R/fza52HzAUQGeicZoI0DlWGnnaUcK2Rxs4o8/z1 M9RZA1dYMtzqPFGK5umO+oYWsQNtViH2RWoYTGPJboA8WkYV+0AIvzRzsKI9kgWeXEzZ AiuFSxHbZAg/LizoAYNoqVepfT8FwEcKZXsFAUXCeizUJpy1Sw5ztnsJ8vv8cdEH9JQh c1SQ== X-Gm-Message-State: ALyK8tJ704R72aNRACDhJ7iM2mT9zX0vX8epiMG32TY+8oX31keIAZmSi35xTQNlu8UzMEgk87eHI6NFajVcOA== MIME-Version: 1.0 X-Received: by 10.37.37.17 with SMTP id l17mr8513554ybl.61.1464632903470; Mon, 30 May 2016 11:28:23 -0700 (PDT) Received: by 10.13.239.3 with HTTP; Mon, 30 May 2016 11:28:23 -0700 (PDT) In-Reply-To: References: Date: Mon, 30 May 2016 20:28:23 +0200 Message-ID: To: Jakub Zelenka Cc: "internals@lists.php.net" , Yasuo Ohgaki Content-Type: multipart/alternative; boundary=001a113d4c1cf019c10534136b97 Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] More precise float value From: nikita.ppv@gmail.com (Nikita Popov) --001a113d4c1cf019c10534136b97 Content-Type: text/plain; charset=UTF-8 On Mon, May 30, 2016 at 6:34 PM, Jakub Zelenka wrote: > On Fri, Sep 4, 2015 at 1:41 AM, Yasuo Ohgaki wrote: > > > Hi all, > > > > IEEE 754 double cannot express exact float values. That said, > > float values expressed by json/serialize/var_export/echo/print > > are not precise enough in many cases. > > > > Issues: > > - json_encode() uses EG(precision)=14 that truncates float values. > > echo()/print() > > does this as well. > > - large EG(precision)/PG(serialize_precision) prints meaningless values. > > > > This RFC proposes zend_dtoa()'s 0 mode support which rounds float value > > to nearest value. > > > > https://wiki.php.net/rfc/precise_float_value > > https://github.com/php/php-src/pull/1455 > > > > This change is simple enough for PHP 7.0. IMO. > > Comments/suggestions are appreciated! > > > > > Hi, > > After asking Yasuo, I'm putting forward this RFC to have more precise float > to string decoding at least in PHP 7.1. I cleaned the RFC up a little bit > and it's targeting just 7.1. > > It has been some time since this was announced so I will keep it open for a > week or two and then plan to start vote. > Thanks for taking over this proposal! I've already mentioned this on the PR when this was originally proposed, but bringing it up here as well: This proposal adds a new json.precision setting. Why? I've been told that this is more flexible, which is fair enough, but imho we should have very strong reasons for introducing new ini settings. Reasons that go beyond "it might be useful to someone ... maybe?" So what's the particular use-case here? Where is it necessary to export inaccurate floating point numbers in JSON? And should such a use-case indeed exist, why is this a global setting rather than an option of json_encode? Furthermore, note that even without this new ini option, you always have the option of temporarily changing serialize_precision for a json_encode call, if you *really* need it. Please also take a look at this comment on the implementation: https://github.com/php/php-src/pull/1455#discussion_r53933480 Regards, Nikita --001a113d4c1cf019c10534136b97--