Bug #77139 [Com]: intval gives wrong results
| From: | spam2 at rhsoft dot net | Date: | Sun, 11 Nov 2018 18:14:04 +0000 |
| Subject: | Bug #77139 [Com]: intval gives wrong results | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-217904@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77139&edit=1
ID: 77139
Comment by: spam2 at rhsoft dot net
Reported by: markus at senoner dot com
Summary: intval gives wrong results
Status: Open
Type: Bug
Package: *Math Functions
Operating System: Linux (any)
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
http://php.net/manual/de/language.types.float.php
Previous Comments:
------------------------------------------------------------------------
[2018-11-11 18:06:02] markus at senoner dot com
Description:
------------
Please try:
echo intval(8.2*1000);
echo intval(8.2*100);
echo intval(8.2*10);
echo intval(8.2*1);
result:
8200
819 <--- this is wrong!
82
8
happens in PHP 7.2 as well as in PHP 5.X
If 819 is the result of an internal representation of 8.2 as 8.199999..., than why does the first
operation in this example not give 8199 ?!?
Expected result:
----------------
8.2*100 should give 820, not 819
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77139&edit=1