Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87347 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25182 invoked from network); 28 Jul 2015 18:15:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jul 2015 18:15:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=jakub.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jakub.php@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.174 as permitted sender) X-PHP-List-Original-Sender: jakub.php@gmail.com X-Host-Fingerprint: 209.85.213.174 mail-ig0-f174.google.com Received: from [209.85.213.174] ([209.85.213.174:37997] helo=mail-ig0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2D/60-22108-DA6C7B55 for ; Tue, 28 Jul 2015 14:15:09 -0400 Received: by iggf3 with SMTP id f3so132778024igg.1 for ; Tue, 28 Jul 2015 11:15:06 -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:content-type; bh=l4fV96zo+W0kq7FpoMxQG4rATj1iTbD3sJdMTHJP/zk=; b=KQ1EfvoN9i8XOBrwTEiFyk/ySBF9PdMEPn9+MMUyVMYUozShi2nq9Msrf8I8m+w706 co2MPx7xVr7whJBtufZPceu4tGv33CYENBzw/JgsWWXBnZw1oLvMmsJc85My1Uxek5P4 5RzI9gQ4TpZhcqvPSReuMMs1KWf2BaqPYgOL/vd19nK2TUuOLMBmushyLKJQlqFf87AE w1M3ewM9BesUYQxFBfXr+Er1HdEKdD7TgZvOC6Nr6VWsRmylDZs6eo4F4g9LNpcis6rv H4CyZLxpgr04zZnP9Oda2dAEU5wF1VTLV0vt6xfOtRu65/psOuvYqyBHRxy2kunZ9Qua BhaA== MIME-Version: 1.0 X-Received: by 10.107.138.13 with SMTP id m13mr61534304iod.24.1438107306423; Tue, 28 Jul 2015 11:15:06 -0700 (PDT) Sender: jakub.php@gmail.com Received: by 10.107.20.68 with HTTP; Tue, 28 Jul 2015 11:15:06 -0700 (PDT) In-Reply-To: References: Date: Tue, 28 Jul 2015 19:15:06 +0100 X-Google-Sender-Auth: kwiFRAtebvpcSPoj_MWEbLVBtwQ Message-ID: To: Yasuo Ohgaki Cc: Anthony Ferrara , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a113f1ef225fbad051bf37304 Subject: Re: [PHP-DEV] json_decode/encode should return full precision values by default From: bukka@php.net (Jakub Zelenka) --001a113f1ef225fbad051bf37304 Content-Type: text/plain; charset=UTF-8 Hi Yasuo On Mon, Jul 27, 2015 at 11:17 PM, Yasuo Ohgaki wrote: > > Get JSON data from Google maps and store the data using PHP, then > users lose last 2 digits of fraction part by default. The value is changed > and wrong. This is definitely a bug. > > I don't really get why you use Google maps as an example. Do you actually know what's the difference between two distances that differs after rounding with precision 14? I just tried it on http://www.ig.utexas.edu/outreach/googleearth/latlong.html and set Lat 1: 51.602097123457 ; Long 1: -0.120667 Lat 2: 51.602097123458 ; Long 2: -0.120667 The difference is 1.114e-10 km which is 0.0001114 millimetres. Are you actually serious about that? :) > We can write > > $old = ini_set('precision', 17); > json_encode($var); > ini_set('precision', $old); > You can set it once in your ini file if you need such precision. > > everywhere to workaround this problem. > > Question is "Is this the way it should be?". > > I have already said that using precision ini wasn't the best idea. However json_encode is not the same as serialize and we should not ever change its output in a bug fixing release. Doing that could cause also other issues as this is a BC break. Lets imagine that someone set low precision on purpose just to limit precision and save some space when transferring data . If you change it, then it's screwed up because it will use different ini. We don't know what people do in their code and we should not break it. As I said this is not a bug but we could consider changing that if the RFC proposing such change passes. Cheers Jakub --001a113f1ef225fbad051bf37304--