Bug #73290 [Opn->Nab]: intval, floor returns invalid result
| From: | cmb@php.net | Date: | Tue, 11 Oct 2016 12:27:32 +0000 |
| Subject: | Bug #73290 [Opn->Nab]: intval, floor returns invalid result | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-204598@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73290&edit=1
ID: 73290
Updated by: cmb@php.net
Reported by: drtzack at gmail dot com
Summary: intval, floor returns invalid result
-Status: Open
+Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: Ubuntu 16.04 x64
PHP Version: 7.0.11
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
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.
You can see what actually happens, if you set the precision to
a high value, see <https://3v4l.org/JvKdr>.
Previous Comments:
------------------------------------------------------------------------
[2016-10-11 11:56:10] drtzack at gmail dot com
Description:
------------
intval(floatval("139.20") * 100) returns invalid result
Test script:
---------------
intval(floatval("139.20") * 100) returns invalid result
Expected result:
----------------
13920
Actual result:
--------------
13919
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73290&edit=1