Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-08-31 Thread Yasuo Ohgaki
Hi all, Sorry, I was a bit busy during August. On Wed, Aug 5, 2015 at 5:37 PM, Yasuo Ohgaki wrote: > I sent work in progress PR for this and updated the RFC. > > https://github.com/php/php-src/pull/1455 > TODO: Add/modify tests. Add 0 mode support for PG(precision). Add >

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-08-05 Thread Yasuo Ohgaki
Hi all, On Fri, Jul 31, 2015 at 4:44 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: On Thu, Jul 30, 2015 at 6:06 PM, Nikita Popov nikita@gmail.com wrote: On Thu, Jul 30, 2015 at 1:25 AM, Yasuo Ohgaki yohg...@ohgaki.net wrote: Hi all, On Thu, Jul 30, 2015 at 7:44 AM, Yasuo Ohgaki

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-31 Thread Yasuo Ohgaki
Hi Nikita, On Thu, Jul 30, 2015 at 6:06 PM, Nikita Popov nikita@gmail.com wrote: On Thu, Jul 30, 2015 at 1:25 AM, Yasuo Ohgaki yohg...@ohgaki.net wrote: Hi all, On Thu, Jul 30, 2015 at 7:44 AM, Yasuo Ohgaki yohg...@ohgaki.net wrote: On Thu, Jul 30, 2015 at 1:13 AM, Nikita Popov

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-30 Thread Nikita Popov
On Thu, Jul 30, 2015 at 1:25 AM, Yasuo Ohgaki yohg...@ohgaki.net wrote: Hi all, On Thu, Jul 30, 2015 at 7:44 AM, Yasuo Ohgaki yohg...@ohgaki.net wrote: On Thu, Jul 30, 2015 at 1:13 AM, Nikita Popov nikita@gmail.com wrote: Instead of continuing to use serialize_precision, which will

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-29 Thread Nikita Popov
On Wed, Jul 29, 2015 at 11:09 AM, Yasuo Ohgaki yohg...@ohgaki.net wrote: Hi Jakub, For me, JSON is one of a data exchange format just like serialize/var_export. Anyway, we are about to reach an agreement. On Wed, Jul 29, 2015 at 5:32 PM, Jakub Zelenka bu...@php.net wrote:

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-29 Thread Yasuo Ohgaki
Hi Nikita, On Thu, Jul 30, 2015 at 1:13 AM, Nikita Popov nikita@gmail.com 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

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-29 Thread Yasuo Ohgaki
Hi all, On Thu, Jul 30, 2015 at 7:44 AM, Yasuo Ohgaki yohg...@ohgaki.net wrote: On Thu, Jul 30, 2015 at 1:13 AM, Nikita Popov nikita@gmail.com wrote: Instead of continuing to use serialize_precision, which will produce unnecessarily long outputs for many values, why don't we just switch

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-29 Thread Ryan Pallas
On Wed, Jul 29, 2015 at 5:25 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: Hi all, On Thu, Jul 30, 2015 at 7:44 AM, Yasuo Ohgaki yohg...@ohgaki.net wrote: On Thu, Jul 30, 2015 at 1:13 AM, Nikita Popov nikita@gmail.com wrote: Instead of continuing to use serialize_precision, which

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-29 Thread Jakub Zelenka
Hi Yasuo, On Tue, Jul 28, 2015 at 10:51 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: Hi Jakub, On Wed, Jul 29, 2015 at 3:15 AM, Jakub Zelenka bu...@php.net wrote: On Mon, Jul 27, 2015 at 11:17 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: Get JSON data from Google maps and store the data

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-29 Thread Yasuo Ohgaki
Hi Jakub, For me, JSON is one of a data exchange format just like serialize/var_export. Anyway, we are about to reach an agreement. On Wed, Jul 29, 2015 at 5:32 PM, Jakub Zelenka bu...@php.net wrote: Question is Is this the way it should be?. I have already said that using precision ini

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-29 Thread Yasuo Ohgaki
Hi Ryan, On Thu, Jul 30, 2015 at 8:35 AM, Ryan Pallas derokor...@gmail.com wrote: 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

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-28 Thread Jakub Zelenka
Hi Yasuo On Mon, Jul 27, 2015 at 11:17 PM, Yasuo Ohgaki yohg...@ohgaki.net 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

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-28 Thread Yasuo Ohgaki
Hi Jakub, On Wed, Jul 29, 2015 at 3:15 AM, Jakub Zelenka bu...@php.net wrote: On Mon, Jul 27, 2015 at 11:17 PM, Yasuo Ohgaki yohg...@ohgaki.net 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

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-27 Thread Jakub Zelenka
Hi Yasuo, On Sun, Jul 26, 2015 at 9:20 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: Hi Jakub, On Mon, Jul 27, 2015 at 3:32 AM, Jakub Zelenka bu...@php.net wrote: I don't think that this is a bug. Your example is also completely unrelated to json because the place when the value is rounded is

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-27 Thread Anthony Ferrara
Yasuo, On Sun, Jul 26, 2015 at 4:20 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: Hi Jakub, On Mon, Jul 27, 2015 at 3:32 AM, Jakub Zelenka bu...@php.net wrote: I don't think that this is a bug. Your example is also completely unrelated to json because the place when the value is rounded is

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-27 Thread Yasuo Ohgaki
On Tue, Jul 28, 2015 at 7:10 AM, Yasuo Ohgaki yohg...@ohgaki.net wrote: On Tue, Jul 28, 2015 at 6:54 AM, Anthony Ferrara ircmax...@gmail.com wrote: On Sun, Jul 26, 2015 at 4:20 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: Hi Jakub, On Mon, Jul 27, 2015 at 3:32 AM, Jakub Zelenka

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-27 Thread Yasuo Ohgaki
Hi Anthony, On Tue, Jul 28, 2015 at 6:54 AM, Anthony Ferrara ircmax...@gmail.com wrote: On Sun, Jul 26, 2015 at 4:20 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: Hi Jakub, On Mon, Jul 27, 2015 at 3:32 AM, Jakub Zelenka bu...@php.net wrote: I don't think that this is a bug. Your example

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-27 Thread Stanislav Malyshev
Hi! We can write $old = ini_set('precision', 17); json_encode($var); ini_set('precision', $old); everywhere to workaround this problem. If we're talking about encoding, that's what precision setting is - it says how much we want to preserve in decimal encoding of float numbers.

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-27 Thread Yasuo Ohgaki
Hi all, On Tue, Jul 28, 2015 at 9:34 AM, Stanislav Malyshev smalys...@gmail.com wrote: We can write $old = ini_set('precision', 17); json_encode($var); ini_set('precision', $old); everywhere to workaround this problem. If we're talking about encoding, that's what precision

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-27 Thread Stanislav Malyshev
Hi! JSON is var exporter/importer like serialize/var_export. Both of serialize/var_export uses PG(serialize_precision), what's the point of _lose_ / _destroy_ original values while PHP could keep more precise values than now? So you're saying JSON should use serialize_precision setting

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-26 Thread Yasuo Ohgaki
Hi Jakub, On Mon, Jul 27, 2015 at 3:32 AM, Jakub Zelenka bu...@php.net wrote: I don't think that this is a bug. Your example is also completely unrelated to json because the place when the value is rounded is var_dump where it's based on ini precision. You would get the same values with

Re: [PHP-DEV] json_decode/encode should return full precision values by default

2015-07-26 Thread Jakub Zelenka
Hi, On Sat, Jul 25, 2015 at 11:01 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: Hi all, I had to work with Google Map API and need to handle values precisely. Fortunately, it seems values are IEEE double, but I get rounded float values by default. For example, ?php $json = ' { results

[PHP-DEV] json_decode/encode should return full precision values by default

2015-07-25 Thread Yasuo Ohgaki
Hi all, I had to work with Google Map API and need to handle values precisely. Fortunately, it seems values are IEEE double, but I get rounded float values by default. For example, ?php $json = ' { results : [ { elevation : 1608.637939453125, location : {