Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93638 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98645 invoked from network); 30 May 2016 19:02:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 May 2016 19:02:00 -0000 Authentication-Results: pb1.pair.com header.from=jakub.php@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=jakub.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.51 as permitted sender) X-PHP-List-Original-Sender: jakub.php@gmail.com X-Host-Fingerprint: 209.85.213.51 mail-vk0-f51.google.com Received: from [209.85.213.51] ([209.85.213.51:36646] helo=mail-vk0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8F/11-26200-42E8C475 for ; Mon, 30 May 2016 15:01:57 -0400 Received: by mail-vk0-f51.google.com with SMTP id a6so24059766vkg.3 for ; Mon, 30 May 2016 12:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc; bh=KZHlfdV6ZNWlrFncjQ+VPi49KXKT4vtjdJQrRjJ5a/g=; b=Oz9Fa9BQj5FwGaUZZsMoPrisMFPKUREOurIFrcxRzvjpzeHpk06gMocEN07VGwQjMc JMT7RwpEO+NUAkMEeqaqPC+0U5pNOM13ZmfTYPraWa1sRChaxxA1uhIJF834cIB8yf6S PHWTVoBBrQCXnZHgqiMJFk9yrPne6oVanxPRTMWiXVjKav1NDvzClrCS0DL0Ui4DZCkw J68oYkz0/i5sWk/lTy9CGLBxg6EgPdkr40pigXFwducDvYYTkKa+YR2VI6qMVq4Y/RA6 T3wnFnYp2B38wzCocYZly7QTEcu+/yo68dyeiyc5ms0e0fVQ1VHcRYoW22QGzXnFg4c7 Ed1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc; bh=KZHlfdV6ZNWlrFncjQ+VPi49KXKT4vtjdJQrRjJ5a/g=; b=i3mQd69tYxCwn1NIQssqgsaoY7pHybti3pZRgJiqhMVUgCPYaiUvjK0tsNZ9knEc9G igJjnh40+2qp52sT2pgpF3TlaXy7uSJt+XdQLk5xzOtqJxsBW4lPhkxKeddujvFuZj1O WAOJjpwSmPigy8naoSA0a6acgy1tmJhipb+8prhWw2xblWb2LtSBLZaevDVQZjkQM0oI tkmoQbm+BPLWaMsW/SqfaLdbGRm4emU9KAwGh3em3o3sJf75+tqkyfYFhppW7QaUQCXH EDSq2vA7j69TidFof2mObRubrYJC7kGa3ZUoRd4z5/CooYeXoivOTT4To6aVk60dQnyb LDSQ== X-Gm-Message-State: ALyK8tLqYBs1mBsYUNElh5nRXaxio+bB/zwYRAd/FrK/o4tOf18d+SrUhVXhTJttzFoqtwx9HYOxQ/MLk5nq3g== MIME-Version: 1.0 X-Received: by 10.159.39.134 with SMTP id b6mr15024584uab.151.1464634913771; Mon, 30 May 2016 12:01:53 -0700 (PDT) Sender: jakub.php@gmail.com Received: by 10.31.172.65 with HTTP; Mon, 30 May 2016 12:01:53 -0700 (PDT) In-Reply-To: References: Date: Mon, 30 May 2016 20:01:53 +0100 X-Google-Sender-Auth: Iljvn-ZPTNCuxWRFLLq2KUwuPd4 Message-ID: To: Nikita Popov Cc: "internals@lists.php.net" , Yasuo Ohgaki Content-Type: multipart/alternative; boundary=94eb2c123cc6c2e249053413e3b0 Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] More precise float value From: bukka@php.net (Jakub Zelenka) --94eb2c123cc6c2e249053413e3b0 Content-Type: text/plain; charset=UTF-8 On Mon, May 30, 2016 at 7:28 PM, Nikita Popov wrote: > 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 > > To be honest I have been thinking again about it before posting it. I thought that it might be good to have at least a voting option or keep it there for discussion but I don't really mind to drop it and just use just serialize_precision by default. I know that it was me who suggested json.precision initialy but it wasn't probably the best idea and it might be a bit confusing for users. If no one thinks that it's useful and we should have a vote about it, I will remove it in the next couple of days. Cheers Jakub --94eb2c123cc6c2e249053413e3b0--