From:             [EMAIL PROTECTED]
Operating system: Windows XP
PHP version:      4.3.10
PHP Bug Type:     Variables related
Bug description:  Bad result for float multiplication

Description:
------------
When multiplying two float, the truncated result is not correct.

Reproduce code:
---------------
<?php
$v1 = (float)0x5a05df1b;
$v2 = (float)0x2d02ef8d;

echo 'v1='.sprintf("0x%X (%d)", $v1, $v1).'<br>';
echo 'v2='.sprintf("0x%X (%d)", $v2, $v2).'<br>';
(float)$v3=(float)$v1*(float)$v2;
echo 'v1*v2='.sprintf("0x%X (%d)", (float)$v3, (float)$v3).'<br>';

// Actual result is :
//   v1=0x5A05DF1B (1510334235)
//   v2=0x2D02EF8D (755167117)
//   v1*v2=0x8DBC1700 (-1917053184)
//
// Result should be : 0xFD410808DBC16DF
// Truncated should be : 0x8DBC16DF

?>

Expected result:
----------------
Result should be : 0xFD410808DBC16DF, because variable is a float, result
should be truncated like that :
0x8DBC16DF

Actual result:
--------------
v1*v2=0x8DBC1700 (-1917053184)

-- 
Edit bug report at http://bugs.php.net/?id=32434&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32434&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=32434&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=32434&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=32434&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=32434&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=32434&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=32434&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=32434&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=32434&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=32434&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=32434&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=32434&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=32434&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32434&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=32434&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=32434&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=32434&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32434&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=32434&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32434&r=mysqlcfg

Reply via email to