Edit report at http://bugs.php.net/bug.php?id=53972&edit=1
ID: 53972 Updated by: johan...@php.net Reported by: thipse_rahul at rediffmail dot com Summary: Operator Type Casting Issue -Status: Open +Status: Bogus Type: Bug Package: *General Issues Operating System: Linux/Windows PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: Floating point values have a limited precision. Hence a value might not have the same string representation after any processing. That also includes writing a floating point value in your script and directly printing it without any mathematical operations. If you would like to know more about "floats" and what IEEE 754 is, read this: http://docs.sun.com/source/806-3568/ncg_goldberg.html Thank you for your interest in PHP. . Previous Comments: ------------------------------------------------------------------------ [2011-02-09 13:56:31] thipse_rahul at rediffmail dot com Description: ------------ Following code snippet -- Case 1: $a = (int)((0.1+0.7) * 10); echo $a; // Result: 7 (Wrong) should give 8 Case 2: $a = (int)((0.1+0.6) * 10); echo $a; // Result: 7 Case 3: $a = (int)((0.1+0.8) * 10); echo $a; // Result: 9 Test script: --------------- $a = (int)((0.1+0.7) * 10); echo $a; Expected result: ---------------- 8 Actual result: -------------- 7 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53972&edit=1