Bug #77149 [Opn->Nab]: Invalid float to integer
| From: | bwoebi@php.net | Date: | Wed, 14 Nov 2018 10:13:28 +0000 |
| Subject: | Bug #77149 [Opn->Nab]: Invalid float to integer | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-217950@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77149&edit=1
ID: 77149
Updated by: bwoebi@php.net
Reported by: antsokol at mail dot ru
Summary: Invalid float to integer
-Status: Open
+Status: Not a bug
Type: Bug
Package: Math related
Operating System: Windows 10 64bit
PHP Version: 7.2.12
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.
Previous Comments:
------------------------------------------------------------------------
[2018-11-14 08:45:03] antsokol at mail dot ru
Description:
------------
Invalid float to integer conversion
Test script:
---------------
$price = 76.24;
$price *= 100;
echo $price . PHP_EOL; //7624
echo (integer)$price . PHP_EOL; //7623
echo intval($price) . PHP_EOL; //7623
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77149&edit=1