#27744 [Bgs]: 141.23 - 141.00 = 0.22999999999999 ?
ID: 27744 User updated by: t dot steve at ariadne-quatra dot com Reported By: t dot steve at ariadne-quatra dot com Status: Bogus Bug Type: Math related Operating System: * PHP Version: * New Comment: Guys, guys, guys... :) I want to make one thing clear: No offense was meant, and I still think PHP is great, and that I learned something new - even though I think this is probably not the correct forum for that. :) I never imagined this would turn out to be such a long discussion - it seems I accidentally touched on something that others came across too. Just as pont of interest: We also use PHP for our (travel agency..) intra+extranet admin system, and among other things, we use PHP-generated forms to order hotel rooms for our clients. At times we get forms requesting a hotel room for 3.999.. nights :)) Now I know why. Thanks again for all the reactions, and keep up the excellent work! :) Previous Comments: [2004-03-31 10:28:25] [EMAIL PROTECTED] For a computer there is simply no such thing as exactly 0.23, it is as simple as that. When displaying floating point numbers, either use printf() and specify the number of significant digits you want or use PHP's precision setting. As for this suggestion: Maybe a magicless solution would be: don't use greater precision then either the minuend or subtrahend (the one with greatest precision). Reducing precision during the calculation would magnify rounding errors greatly when doing a series of operations on the floating point values. You want to apply lower precision at the end at display time, not during the calculation. And at display time we don't know what the precicion of the operands were that led to this value which is why you need to explicitly express what precision you want values displayed at. [2004-03-31 06:41:40] garbo_doe at hotmail dot com echo (string)(75000.00 - 74999.00); returns 1, not 0.99. Is this a bug then? ;) Guys, how in the world is PHP supposed to magically guess what precision you want results displayed in. Maybe a magicless solution would be: don't use greater precision then either the minuend or subtrahend (the one with greatest precision). Thanks for you answers and for PHP - it's great! :-) (I hope I'm not too annoying continuing this discussion...I sense some irritation, we have already explained, on this matter :-) [2004-03-31 03:12:23] [EMAIL PROTECTED] Since you don't believe us: http://docs.sun.com/source/806-3568/ncg_goldberg.html [2004-03-30 21:40:21] [EMAIL PROTECTED] Floating point values in computers are never exact. It's a fact of life, and an issue that is not only encountered with PHP but other languages as well. [2004-03-30 21:35:54] t dot steve at ariadne-quatra dot com Hi! I am sure I am something, apologies for that. :( Guys, how in the world is PHP supposed to magically guess what precision you want results displayed in. 141.23 - 141 _is_ precisely 0.23. If I was asking for 1/3, then I would understand the decimal places. But how come 141.23-141 turns out to have so many decimal places in the end instead of just being 0.23 - the mathematically correct and precise result? The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/27744 -- Edit this bug report at http://bugs.php.net/?id=27744edit=1
#27744 [Bgs]: 141.23 - 141.00 = 0.22999999999999 ?
ID: 27744 User updated by: t dot steve at ariadne-quatra dot com Reported By: t dot steve at ariadne-quatra dot com Status: Bogus Bug Type: Math related Operating System: * PHP Version: * New Comment: Hi! I am sure I am something, apologies for that. :( Guys, how in the world is PHP supposed to magically guess what precision you want results displayed in. 141.23 - 141 _is_ precisely 0.23. If I was asking for 1/3, then I would understand the decimal places. But how come 141.23-141 turns out to have so many decimal places in the end instead of just being 0.23 - the mathematically correct and precise result? Previous Comments: [2004-03-30 19:59:05] [EMAIL PROTECTED] Guys, how in the world is PHP supposed to magically guess what precision you want results displayed in. If you know you always want lower precision, set that in your php.ini file. Or if you just want it temporarily simply do: $old = ini_set('precision',2); echo (string)(750 - 749.99); ini_set('precision',$old); [2004-03-30 19:47:47] [EMAIL PROTECTED] create table a ( b float,c float ); Query OK, 0 rows affected (0.11 sec) mysql insert into a (b,c) values (141.23,141); Query OK, 1 row affected (0.07 sec) mysql select b-c from a; +--+ | b-c | +--+ | 0.22999572753906 | +--+ 1 row in set (0.00 sec) [2004-03-30 13:45:03] [EMAIL PROTECTED] That is the whole point of the answer. Floating point values are not accurate and are not nice. And we do not do a bunch of work just to make them look better in certain circumstances. [2004-03-30 12:07:45] garbo_doe at hotmail dot com IMHO I think this is a bug. Of course there are problems with floatingpoint values in binary form, especially when rounded many times. But in an operation like ?php echo (string)(750 - 749.99) ? it shouldn't return 0.00 but 0.01. I did a quick test in Delphi: showmessage(floattostr(750 - 749.99)); returns 0.01, not 0.00. I had to solve it in PHP but multiplying with 100, then subtract and then divide the result by 100 again. It's not pretty :-D (0.00999[infinite 9's] IS exactly the same as 0.01, but it should remember the infinite with a bit or something, so (1/3)*3 = 1 and not 0.9) (this is similar as bug #8164) [2004-03-29 01:06:46] [EMAIL PROTECTED] 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. Thank you for your interest in PHP. . The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/27744 -- Edit this bug report at http://bugs.php.net/?id=27744edit=1
#27744 [NEW]: 141.23 - 141.00 = 0.22999999999999 ?
From: t dot steve at ariadne-quatra dot com Operating system: Windows 2000 Server SP4 PHP version: 5.0.0RC1 PHP Bug Type: Math related Bug description: 141.23 - 141.00 = 0.22 ? Description: Subtraction does not work as expected. Windows 2000 Server SP4 IIS5 PHP5RC1 Reproduce code: --- $result=141.23-141.00; echo $result; (or $result=141.23-141; echo $result; - same result) Expected result: 0.23 Actual result: -- 0.22 -- Edit bug report at http://bugs.php.net/?id=27744edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27744r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27744r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=27744r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=27744r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=27744r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=27744r=needscript Try newer version: http://bugs.php.net/fix.php?id=27744r=oldversion Not developer issue:http://bugs.php.net/fix.php?id=27744r=support Expected behavior: http://bugs.php.net/fix.php?id=27744r=notwrong Not enough info:http://bugs.php.net/fix.php?id=27744r=notenoughinfo Submitted twice:http://bugs.php.net/fix.php?id=27744r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=27744r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27744r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=27744r=dst IIS Stability: http://bugs.php.net/fix.php?id=27744r=isapi Install GNU Sed:http://bugs.php.net/fix.php?id=27744r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=27744r=float
#26618 [Opn]: Using % % tags makes include() not to work (sometimes)
ID: 26618 User updated by: t dot steve at ariadne-quatra dot com Reported By: t dot steve at ariadne-quatra dot com Status: Open Bug Type: IIS related Operating System: Windows 2000 server SP4 PHP Version: 5CVS-2003-12-14 New Comment: Another note: This cannot be an IIS related bug, it must be related to PHP itself since all previous versions of PHP worked fine even with the ASP delimiters (% %) which I have to use. The problem arose only as of version 5.x - including the latest build which I just tested. Previous Comments: [2003-12-16 03:04:33] t dot steve at ariadne-quatra dot com YES, with conventional ?php ? tags the includes work perfectly and consistently! :) However, this IS still a problem - I need to use the % % because of the editor I must use (FP...)! ASP-style tags ARE - in theory - supported, aren't they? (They are enabled in the INI file, and I have been using them in all our sites for ages without any problems!) So then the problem changes to ASP-style % % tags versus regular ?php ? tags... Do I have to open a new bug report, or just leave this one open? Thanks! [2003-12-16 02:48:32] [EMAIL PROTECTED] Try using the PHP tags, not those ugly ASP tags. (% % - ?php ?) [2003-12-14 10:46:58] t dot steve at ariadne-quatra dot com Description: PHP5 beta2 IIS5 Windows 2000 SP4 ISAPI mode - Worked correctly with PHP4.3.4 with Zend 2.0.1 - With PHP5 beta2 (also ISAPI mode) a simple PHP page which uses include_once([local path]) to include the menu part of a web page sometimes works, sometimes does not (sometimes the menu is included, sometimes it is not). (There is only the single include_once in the code, so this is NOT an issue of my trying to include something twice with include_ONCE... ) - The page contains NO other PHP code, just the lines below: % include_once(c:/wwwroot/domain.com/english/inc/header.inc); % (html_head.inc is the file to be included, it contains only html code, no php) - Again, note that the exact same page, exact same setup works fine under 4.3.4 - and has done so with previous versions! - Under PHP5, with every refresh of the page the inclusion of the file is erratic - every few refreshes the inclusion is not done. If you need any part of my php.ini, let me know please. Thanks, Steve Reproduce code: --- html head titleThe world of services/title /head body % include_once(c:/wwwroot/domain.com/english/inc/header.inc); % Please select from the menu on the left! /body /html Expected result: A page with the menu on the left (created fromt he included file), plus the contents. Actual result: -- Only the contents apperas, the inclusion is not done. -- Edit this bug report at http://bugs.php.net/?id=26618edit=1
#26618 [Fbk-Opn]: include_once() sometimes works, sometimes doesn't with each page refresh
ID: 26618 User updated by: t dot steve at ariadne-quatra dot com Reported By: t dot steve at ariadne-quatra dot com -Status: Feedback +Status: Open Bug Type: Zend Engine 2 problem Operating System: Windows 2000 server SP4 PHP Version: 5CVS-2003-12-14 New Comment: YES, with conventional ?php ? tags the includes work perfectly and consistently! :) However, this IS still a problem - I need to use the % % because of the editor I must use (FP...)! ASP-style tags ARE - in theory - supported, aren't they? (They are enabled in the INI file, and I have been using them in all our sites for ages without any problems!) So then the problem changes to ASP-style % % tags versus regular ?php ? tags... Do I have to open a new bug report, or just leave this one open? Thanks! Previous Comments: [2003-12-16 02:48:32] [EMAIL PROTECTED] Try using the PHP tags, not those ugly ASP tags. (% % - ?php ?) [2003-12-15 22:04:48] t dot steve at ariadne-quatra dot com - No, I get no errors even after adding 'error_reporting(E_ALL);'. - Yes, the same behaviour even if I use include() instead of include_once(). [2003-12-15 09:25:33] [EMAIL PROTECTED] Do you get any errors if you put 'error_reporting(E_ALL);' before the include_once() line? Does this happen if you use include() ? [2003-12-15 08:40:15] t dot steve at ariadne-quatra dot com The same :( - includes are done eratically. A note here: this is also the case if I start to wander around the site (as opposed to just refreshing the same page again and again), i.e. as the various pages are loaded, sometimes the inlude is done, sometimes it is not. [2003-12-14 20:21:56] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/26618 -- Edit this bug report at http://bugs.php.net/?id=26618edit=1
#26618 [Fbk-Opn]: include_once() sometimes works, sometimes doesn't with each page refresh
ID: 26618 User updated by: t dot steve at ariadne-quatra dot com Reported By: t dot steve at ariadne-quatra dot com -Status: Feedback +Status: Open Bug Type: Zend Engine 2 problem Operating System: Windows 2000 server SP4 PHP Version: 5.0.0b2 (beta2) New Comment: The same :( - includes are done eratically. A note here: this is also the case if I start to wander around the site (as opposed to just refreshing the same page again and again), i.e. as the various pages are loaded, sometimes the inlude is done, sometimes it is not. Previous Comments: [2003-12-14 20:21:56] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip [2003-12-14 10:46:58] t dot steve at ariadne-quatra dot com Description: PHP5 beta2 IIS5 Windows 2000 SP4 ISAPI mode - Worked correctly with PHP4.3.4 with Zend 2.0.1 - With PHP5 beta2 (also ISAPI mode) a simple PHP page which uses include_once([local path]) to include the menu part of a web page sometimes works, sometimes does not (sometimes the menu is included, sometimes it is not). (There is only the single include_once in the code, so this is NOT an issue of my trying to include something twice with include_ONCE... ) - The page contains NO other PHP code, just the lines below: % include_once(c:/wwwroot/domain.com/english/inc/header.inc); % (html_head.inc is the file to be included, it contains only html code, no php) - Again, note that the exact same page, exact same setup works fine under 4.3.4 - and has done so with previous versions! - Under PHP5, with every refresh of the page the inclusion of the file is erratic - every few refreshes the inclusion is not done. If you need any part of my php.ini, let me know please. Thanks, Steve Reproduce code: --- html head titleThe world of services/title /head body % include_once(c:/wwwroot/domain.com/english/inc/header.inc); % Please select from the menu on the left! /body /html Expected result: A page with the menu on the left (created fromt he included file), plus the contents. Actual result: -- Only the contents apperas, the inclusion is not done. -- Edit this bug report at http://bugs.php.net/?id=26618edit=1
#26618 [Fbk-Opn]: include_once() sometimes works, sometimes doesn't with each page refresh
ID: 26618 User updated by: t dot steve at ariadne-quatra dot com Reported By: t dot steve at ariadne-quatra dot com -Status: Feedback +Status: Open Bug Type: Zend Engine 2 problem Operating System: Windows 2000 server SP4 PHP Version: 5CVS-2003-12-14 New Comment: - No, I get no errors even after adding 'error_reporting(E_ALL);'. - Yes, the same behaviour even if I use include() instead of include_once(). Previous Comments: [2003-12-15 09:25:33] [EMAIL PROTECTED] Do you get any errors if you put 'error_reporting(E_ALL);' before the include_once() line? Does this happen if you use include() ? [2003-12-15 08:40:15] t dot steve at ariadne-quatra dot com The same :( - includes are done eratically. A note here: this is also the case if I start to wander around the site (as opposed to just refreshing the same page again and again), i.e. as the various pages are loaded, sometimes the inlude is done, sometimes it is not. [2003-12-14 20:21:56] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip [2003-12-14 10:46:58] t dot steve at ariadne-quatra dot com Description: PHP5 beta2 IIS5 Windows 2000 SP4 ISAPI mode - Worked correctly with PHP4.3.4 with Zend 2.0.1 - With PHP5 beta2 (also ISAPI mode) a simple PHP page which uses include_once([local path]) to include the menu part of a web page sometimes works, sometimes does not (sometimes the menu is included, sometimes it is not). (There is only the single include_once in the code, so this is NOT an issue of my trying to include something twice with include_ONCE... ) - The page contains NO other PHP code, just the lines below: % include_once(c:/wwwroot/domain.com/english/inc/header.inc); % (html_head.inc is the file to be included, it contains only html code, no php) - Again, note that the exact same page, exact same setup works fine under 4.3.4 - and has done so with previous versions! - Under PHP5, with every refresh of the page the inclusion of the file is erratic - every few refreshes the inclusion is not done. If you need any part of my php.ini, let me know please. Thanks, Steve Reproduce code: --- html head titleThe world of services/title /head body % include_once(c:/wwwroot/domain.com/english/inc/header.inc); % Please select from the menu on the left! /body /html Expected result: A page with the menu on the left (created fromt he included file), plus the contents. Actual result: -- Only the contents apperas, the inclusion is not done. -- Edit this bug report at http://bugs.php.net/?id=26618edit=1
#26618 [Fbk-Opn]: include_once() sometimes works, sometimes doesn't with each page refresh
ID: 26618 User updated by: t dot steve at ariadne-quatra dot com Reported By: t dot steve at ariadne-quatra dot com -Status: Feedback +Status: Open Bug Type: Zend Engine 2 problem Operating System: Windows 2000 server SP4 PHP Version: 5CVS-2003-12-14 New Comment: I always downloaded http://snaps.php.net/win32/php5-win32-latest.zip each time I tried something new! It was no different this time - a new download and install before I tried what you requested! (No local proxy or cache - I am downloading the actual file each time!) I have ALL PHP-related DLLs in my PHP dir, nothing in WINNT and so on... I checked and double-checked! Each time I want to try PHP5 this is what I do: - stop IIS - rename PHP (whcih is where my current PHP version resides) to PHP4 - create a new, empty PHP dir, and expand the downloaded ZIP in there - copy the php4isapi.dll from the sapi folder up one level to the PHP folder (this is how I have IIS set up) - no need to move anything anywhere else, my system is set up so that there is no need to copy any DLLS to the WINNT directory (I also checked to make sure there are none there - there aren't!) - then restart IIS - test... Please let me know if there is anything else I can do to help! Many thanks! Steve Previous Comments: [2003-12-15 23:58:55] [EMAIL PROTECTED] Are you absolutely sure you are using the latest CVS snapshot? Grab the latest now, remove ALL (and I mean _all_) php related dlls from your system before you install it. Most important one being php4ts.dll (make sure you only have ONE of those around). Also make sure IIS is not running when you install PHP.. [2003-12-15 22:04:48] t dot steve at ariadne-quatra dot com - No, I get no errors even after adding 'error_reporting(E_ALL);'. - Yes, the same behaviour even if I use include() instead of include_once(). [2003-12-15 09:25:33] [EMAIL PROTECTED] Do you get any errors if you put 'error_reporting(E_ALL);' before the include_once() line? Does this happen if you use include() ? [2003-12-15 08:40:15] t dot steve at ariadne-quatra dot com The same :( - includes are done eratically. A note here: this is also the case if I start to wander around the site (as opposed to just refreshing the same page again and again), i.e. as the various pages are loaded, sometimes the inlude is done, sometimes it is not. [2003-12-14 20:21:56] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/26618 -- Edit this bug report at http://bugs.php.net/?id=26618edit=1
#26618 [Opn]: include_once() sometimes works, sometimes doesn't with each page refresh
ID: 26618 User updated by: t dot steve at ariadne-quatra dot com Reported By: t dot steve at ariadne-quatra dot com Status: Open Bug Type: Zend Engine 2 problem Operating System: Windows 2000 server SP4 PHP Version: 5CVS-2003-12-14 New Comment: Sorry, to clarify: by It was no different this time - ... I meant that I did it the same way this time as well. Previous Comments: [2003-12-16 00:11:22] t dot steve at ariadne-quatra dot com I always downloaded http://snaps.php.net/win32/php5-win32-latest.zip each time I tried something new! It was no different this time - a new download and install before I tried what you requested! (No local proxy or cache - I am downloading the actual file each time!) I have ALL PHP-related DLLs in my PHP dir, nothing in WINNT and so on... I checked and double-checked! Each time I want to try PHP5 this is what I do: - stop IIS - rename PHP (whcih is where my current PHP version resides) to PHP4 - create a new, empty PHP dir, and expand the downloaded ZIP in there - copy the php4isapi.dll from the sapi folder up one level to the PHP folder (this is how I have IIS set up) - no need to move anything anywhere else, my system is set up so that there is no need to copy any DLLS to the WINNT directory (I also checked to make sure there are none there - there aren't!) - then restart IIS - test... Please let me know if there is anything else I can do to help! Many thanks! Steve [2003-12-15 23:58:55] [EMAIL PROTECTED] Are you absolutely sure you are using the latest CVS snapshot? Grab the latest now, remove ALL (and I mean _all_) php related dlls from your system before you install it. Most important one being php4ts.dll (make sure you only have ONE of those around). Also make sure IIS is not running when you install PHP.. [2003-12-15 22:04:48] t dot steve at ariadne-quatra dot com - No, I get no errors even after adding 'error_reporting(E_ALL);'. - Yes, the same behaviour even if I use include() instead of include_once(). [2003-12-15 09:25:33] [EMAIL PROTECTED] Do you get any errors if you put 'error_reporting(E_ALL);' before the include_once() line? Does this happen if you use include() ? [2003-12-15 08:40:15] t dot steve at ariadne-quatra dot com The same :( - includes are done eratically. A note here: this is also the case if I start to wander around the site (as opposed to just refreshing the same page again and again), i.e. as the various pages are loaded, sometimes the inlude is done, sometimes it is not. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/26618 -- Edit this bug report at http://bugs.php.net/?id=26618edit=1
#26618 [NEW]: include_once() sometimes works, sometimes doesn't with each page refresh
From: t dot steve at ariadne-quatra dot com Operating system: Windows 2000 server SP4 PHP version: 5.0.0b2 (beta2) PHP Bug Type: Unknown/Other Function Bug description: include_once() sometimes works, sometimes doesn't with each page refresh Description: PHP5 beta2 IIS5 Windows 2000 SP4 ISAPI mode - Worked correctly with PHP4.3.4 with Zend 2.0.1 - With PHP5 beta2 (also ISAPI mode) a simple PHP page which uses include_once([local path]) to include the menu part of a web page sometimes works, sometimes does not (sometimes the menu is included, sometimes it is not). (There is only the single include_once in the code, so this is NOT an issue of my trying to include something twice with include_ONCE... ) - The page contains NO other PHP code, just the lines below: % include_once(c:/wwwroot/domain.com/english/inc/header.inc); % (html_head.inc is the file to be included, it contains only html code, no php) - Again, note that the exact same page, exact same setup works fine under 4.3.4 - and has done so with previous versions! - Under PHP5, with every refresh of the page the inclusion of the file is erratic - every few refreshes the inclusion is not done. If you need any part of my php.ini, let me know please. Thanks, Steve Reproduce code: --- html head titleThe world of services/title /head body % include_once(c:/wwwroot/domain.com/english/inc/header.inc); % Please select from the menu on the left! /body /html Expected result: A page with the menu on the left (created fromt he included file), plus the contents. Actual result: -- Only the contents apperas, the inclusion is not done. -- Edit bug report at http://bugs.php.net/?id=26618edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26618r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26618r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=26618r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=26618r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=26618r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=26618r=needscript Try newer version: http://bugs.php.net/fix.php?id=26618r=oldversion Not developer issue:http://bugs.php.net/fix.php?id=26618r=support Expected behavior: http://bugs.php.net/fix.php?id=26618r=notwrong Not enough info:http://bugs.php.net/fix.php?id=26618r=notenoughinfo Submitted twice:http://bugs.php.net/fix.php?id=26618r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=26618r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26618r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=26618r=dst IIS Stability: http://bugs.php.net/fix.php?id=26618r=isapi Install GNU Sed:http://bugs.php.net/fix.php?id=26618r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=26618r=float