Edit report at https://bugs.php.net/bug.php?id=64742&edit=1
ID: 64742 Updated by: [email protected] Reported by: bondo dot the dot clown at gmail dot com Summary: float(1) casts to int as 0 -Status: Open +Status: Not a bug Type: Bug Package: Math related Operating System: linux PHP Version: Irrelevant 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://www.floating-point-gui.de/ Thank you for your interest in PHP. 8.95 - 7.95 is not exactly 1 (int) rounds down. $ php -d precision=99 -r 'echo 8.95 - 7.95;' 0.99999999999999911182158029987476766109466552734375 Previous Comments: ------------------------------------------------------------------------ [2013-04-30 14:37:11] bondo dot the dot clown at gmail dot com Description: ------------ code speaks for himself php --version PHP 5.4.6-1ubuntu1.2 (cli) (built: Mar 11 2013 14:57:54) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies with XCache v2.0.0, Copyright (c) 2005-2012, by mOo with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans Test script: --------------- echo (int)(8.95 - 7.95); Expected result: ---------------- 1 Actual result: -------------- 0 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64742&edit=1
