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 var_dump
>> where it's based on ini precision. You would get the same values with
>> json_encode but it's only because it uses the same ini ( precision ).
>> Basically it has nothing to do with json_decode.
>>
>
> OK. Better example.
>
> [yohgaki@dev PHP-master]$ ./php-bin
> <?php
> $j = '{ "v": 0.1234567890123456789 }';
> var_dump(json_encode(json_decode($j)));
> ini_set('precision', 20);
> var_dump(json_encode(json_decode($j)));
> ?>
>
>
> string(22) "{"v":0.12345678901235}"
> string(28) "{"v":0.12345678901234567737}"

I think you missed the point. Parsing isn't dependent upon precision
setting. Only dumping: http://3v4l.org/48VSt

$j = '{ "v": 0.1234567890123456789 }';
$d1 = json_decode($j);

ini_set('precision', 20);

$d2 = json_decode($j);

var_dump($d1, $d2);

//object(stdClass)#1 (1) { ["v"]=> float(0.12345678901234567737) }
//object(stdClass)#2 (1) { ["v"]=> float(0.12345678901234567737) }

Meaning that it's parsed correctly.

There is no bug here.

Anthony

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to