|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-08-12 14:18 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2016-08-12 14:18 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 19:00:02 2025 UTC |
Description: ------------ The magic number is: 0.2 or -0.2 number - number = 0.2 or -0.2 then int conversion return bad result. I tried with (int) or intval. Same result. We tried with Win7, Win10 and Ubuntu 16.04 ubuntu's php version (official, installed with ap-get): PHP 7.0.8-0ubuntu0.16.04.2 (cli) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.8-0ubuntu0.16.04.2, Copyright (c) 1999-2016, by Zend Technologies Test script: --------------- <?php echo "<pre>"; $var = (1-1.2)*100; var_dump($var); //float(-20) $var2 = (-0.2)*100; var_dump($var2); //float(-20) $var_int = (int)$var; var_dump($var_int); //int(-19) ** INCORRECT RESULT ** $var2_int = (int)$var2; var_dump($var2_int); //int(-20) echo "</pre>"; //I changed values and no problem echo "<pre>"; $var = (2-1.2)*100; var_dump($var); //float(80) $var2 = (0.8)*100; var_dump($var2); //float(80) $var_int = (int)$var; var_dump($var_int); //int(80) $var2_int = (int)$var2; var_dump($var2_int); //int(80) echo "</pre>";