php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79866 yaml_emit looses decimals on floats/doubles
Submitted: 2020-07-16 11:23 UTC Modified: 2020-08-16 03:52 UTC
From: gaaf at gmx dot net Assigned: bd808 (profile)
Status: Closed Package: yaml (PECL)
PHP Version: 7.4.8 OS:
Private report: No CVE-ID: None
 [2020-07-16 11:23 UTC] gaaf at gmx dot net
Description:
------------
yaml_emit will limit the number of decimals to 6, a that is the default precision for snprintf used by the module to convert the double to a string.

I would expect the resulting yaml to contain the exact same number as "echo" would print.



Test script:
---------------
<?php

$i = 0.123456789;

echo $i;
// 0.123456789

echo yaml_emit($i);
// --- 0.123457
// ...


Expected result:
----------------
0.123456789
--- 0.123456789
...


Actual result:
--------------
0.123456789
--- 0.123457
...


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-16 03:52 UTC] bd808@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: bd808
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Oct 19 22:01:23 2020 UTC