Bug #64534 [NEW]: Bad transfer variable from double to integer with specific number
| From: | izolex4 at gmail dot com | Date: | Wed, 27 Mar 2013 15:16:12 +0000 |
| Subject: | Bug #64534 [NEW]: Bad transfer variable from double to integer with specific number | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-178148@lists.php.net to get a copy of this message | ||
From: izolex4 at gmail dot com
Operating system: Linux
PHP version: 5.3Git-2013-03-27 (Git)
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Bad transfer variable from double to integer with specific number
Description:
------------
I have variable with type "double" with value 16.90 or 17.90 or 18.90 or
19.90.
Now multiply variable x 100 and now set type of variable to "integer" with
function "settype" and print this variable. Result will for example: 1989,
even
that correct result is 1990. This make only, when original value is 16.90
or 17.90
or 18.90 or 19.90. If is original value another (for example 10.90 or
19.80),
result will
be correct (for example 1090 or 1980), but now is result incorrect for
example
1989.
Test script:
---------------
<?php
$double = 19.90; // Only 16.90 or 17.90 or 18.90 or 19.90 will print bad
result
$integer = $double*100; // Now is value 1990
settype($integer, 'integer'); // This change value to 1989 - bug
echo $integer;
Expected result:
----------------
Value of "integer" - 1990
Actual result:
--------------
Value of "integer" - 1989
--
Edit bug report at https://bugs.php.net/bug.php?id=64534&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64534&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64534&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64534&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64534&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64534&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64534&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64534&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64534&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64534&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64534&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=64534&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=64534&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64534&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64534&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64534&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64534&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64534&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64534&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64534&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64534&r=mysqlcfg