From:             joern at hv23 dot net
Operating system: Mac OSX + Linux
PHP version:      5.4.10
Package:          Variables related
Bug Type:         Bug
Bug description:Unexpected result of  int() conversion

Description:
------------
Putting an (int) in front of brackets creates a wrong result - or at least
an 
unexpected result.

Output of below script is actually:

input = 0.58, output = 57
test3 = 58
test4 = 57

("0.58"*100) creates a correct 58 
(int) ("0.58"*100) gives an incorrect 57

The same happens with input of "0.29", where the output = is 28.

It happens on intel as well as AMD cpus.

Test script:
---------------
$test = "0.58";
$test2 = (int) ($test*100);
$test3 = ($test*100);
$test4 = (int) ($test*100);

echo "input = $test, output = $test2\n";
echo "test3 = $test3\n";
echo "test4 = $test4\n";


Expected result:
----------------
I would expect the output to be:
input = 0.58, output = 57
test3 = 58
test4 = 58

Actual result:
--------------
Current output:

input = 0.58, output = 57
test3 = 58
test4 = 57

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63960&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63960&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63960&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63960&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63960&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63960&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63960&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63960&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63960&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63960&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63960&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63960&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63960&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63960&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63960&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63960&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63960&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63960&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63960&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63960&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63960&r=mysqlcfg

Reply via email to