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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
21 + 5 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 00:01:41 2024 UTC