php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75213 Float/Exponential values incorrectly parsed
Submitted: 2017-09-15 15:32 UTC Modified: 2018-11-13 03:02 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: neclimdul at gmail dot com Assigned: bd808 (profile)
Status: Closed Package: yaml (PECL)
PHP Version: 7.1.9 OS: alpine
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: neclimdul at gmail dot com
New email:
PHP Version: OS:

 

 [2017-09-15 15:32 UTC] neclimdul at gmail dot com
Description:
------------
There seems to be a bug with float values out of YAML files.

Originally found here:
https://www.drupal.org/node/2882708

"3.1415" is parsed as "3.1415900000001784" and "1.2e+34" is parsed as "1.2000000000000467E+34"

This is only happens in alpine. It is not present in ruby on alpine though so I'm not sure if its musl related or if ruby works around it.



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

var_dump(yaml_parse('
  - 3.1415
  - 1.2e+30
'));

Expected result:
----------------
array(2) {
  [0]=>
  float(3.1415)
  [1]=>
  float(1.2E+30)
}


Actual result:
--------------
array(2) {
  [0]=>
  float(3.1414999999997)
  [1]=>
  float(1.1999999999999E+30)
}


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-09-15 15:52 UTC] neclimdul at gmail dot com
Added a git repo that has some docker resources that help demonstrate this.

https://github.com/neclimdul/pecl_yaml_alpine_bug/
 [2017-09-15 16:26 UTC] neclimdul at gmail dot com
Addition note, I just confirmed that while the scripts provided are helpful for demonstrating the issue quickly and easily, running `make test` in alpine actually fails and catches this problem in a couple different tests.
 [2017-09-15 18:30 UTC] neclimdul at gmail dot com
Don't know if it is the right solution but this fixes the bug.

https://github.com/php/pecl-file_formats-yaml/pull/29
 [2018-11-13 01:23 UTC] bd808@php.net
-Assigned To: +Assigned To: bd808
 [2018-11-13 03:02 UTC] bd808@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Dec 16 14:01:26 2018 UTC