ID: 32434 User updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Feedback +Status: Open Bug Type: Variables related Operating System: Windows XP PHP Version: 4.3.10 New Comment:
I'm maintaining a PHP library that generate or extract zip files in PHP (PclZip on www.phpconcept.net). Today this library does not support zip encryption. To support zip encryption I need to do this kind of complex math ... The code for encryption is quite ready, but failed because of this float truncate. I wrote the bug report, because if it's a bug, and that it can be solved, I will have the ability to propose this encryption feature. If it can not be solved, then I will not try any more to do encryption with PclZip. Thanks for your support ! Vincent Previous Comments: ------------------------------------------------------------------------ [2005-03-23 21:42:16] [EMAIL PROTECTED] Why are you doing things like this? ------------------------------------------------------------------------ [2005-03-23 21:11:07] [EMAIL PROTECTED] 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 this bug report at http://bugs.php.net/?id=32434&edit=1