ID: 48462 Updated by: j...@php.net Reported By: courtois at nouvo dot com -Status: Open +Status: Bogus Bug Type: Strings related Operating System: XP PHP Version: 5.2.9 New Comment:
Your C program is not same as what PHP does, try change the float to double.. Previous Comments: ------------------------------------------------------------------------ [2009-06-03 17:03:11] courtois at nouvo dot com Description: ------------ This a followup to bug #48455 which has been closed. I observed same bug with different values. I'm affraid rasmus' answer is incorrect. 3498 is represented with 12 bits. A float holds 24 bits which is far enough to contain 3498 without any single bit of precision loss. Anyway, the same program in C works fine: #include <stdio.h> main() { float f; f=34.98*100; printf("%6d %f\n",(int)f,f); } thus the problem is NOT with the float representation. Moreover the following script should return twice the same thing: $x=34.98*100; print "x:".$x." sprintf:".sprintf('%d',$x); but the unexpected result is: x:3498 sprintf:3497 If the first conversion from float to string works fine, why doesn't the second conversion work ? ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48462&edit=1