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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gaaf at gmx dot net
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue May 13 09:01:27 2025 UTC