Bug #79443 [Com]: round with precision is not rounding
| From: | info at globules dot io | Date: | Wed, 01 Apr 2020 16:10:18 +0000 |
| Subject: | Bug #79443 [Com]: round with precision is not rounding | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-226396@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79443&edit=1
ID: 79443
Comment by: info at globules dot io
Reported by: info at globules dot io
Summary: round with precision is not rounding
Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: Windows 10 x64
PHP Version: 7.4.4
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
How is this not a bug?
This is the exact code. I'm rounding with precision, it works on Linux, doesn't work on
Windows.
Previous Comments:
------------------------------------------------------------------------
[2020-04-01 16:06:34] info at globules dot io
Yes I have posted the exact code.
------------------------------------------------------------------------
[2020-04-01 15:48:07] danack@php.net
Mr Info
Are you sure that code you posted is actually the code that's producing that output?
https://3v4l.org/v9k54
------------------------------------------------------------------------
[2020-04-01 15:44:09] cmb@php.net
Floating point values have a limited precision. Hence a value might
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly
printing it without any mathematical operations.
If you would like to know more about "floats" and what IEEE
754 is, read this:
http://www.floating-point-gui.de/
Thank you for your interest in PHP.
------------------------------------------------------------------------
[2020-04-01 15:41:50] info at globules dot io
Description:
------------
round with precision is not rounding
Test script:
---------------
echo round(-80.0035326999999938, 6);
Expected result:
----------------
-80.003533
Actual result:
--------------
-80.0035330000000044
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79443&edit=1