Ask a Question related to PHP Bugs, Design and Development.
-
bruno dot boccara at d2b dot com #1
#40622 [NEW]: round function
From: bruno dot boccara at d2b dot com
Operating system: windows 2003 Apache 2
PHP version: 4.4.5
PHP Bug Type: Math related
Bug description: round function
Description:
------------
round function gives wrong value.
Please do not send me to
[url]http://docs.sun.com/source/806-3568/ncg_goldberg.html[/url], you have to admit
that this is a bug !!!!!
if not, php CANNOT be use in production site with mathematical functions
!!!
Reproduce code:
---------------
<?
// 140.25*(1-(34/100)) = 92.565
echo "formula = ". round(((140.25*(1-(34/100)))),2);echo "<br>";
echo "direct = ".round (92.565, 2);echo "<br>";
$valeur = 140.25*(1-(34/100));
echo "value = ".round($valeur,2);echo "<br>";
settype($valeur,"string");
settype($valeur,"float");
echo "value2 = ".round($valeur,2);
?>
Expected result:
----------------
formula = 92.57
direct = 92.57
value = 92.57
value2 = 92.57
Actual result:
--------------
formula = 92.56 // WRONG !
direct = 92.57
value = 92.56 // WRONG !
value2 = 92.57
--
Edit bug report at [url]http://bugs.php.net/?id=40622&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40622&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40622&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40622&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40622&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=40622&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=40622&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40622&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=40622&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=40622&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=40622&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=40622&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=40622&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=40622&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40622&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=40622&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=40622&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40622&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=40622&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40622&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40622&r=mysqlcfg[/url]
bruno dot boccara at d2b dot com Guest
-
sharedobject second round does not function :S
Hello there i have this code with two buttoms. First the sharedobject is empty.. (trace undefined) then i add a attribute to the sharedobject (... -
Using the round function
I have this placed in my code <%Response.write(Session("MembershipCost"))%> the number it contains is 605 how do i use the round Function to... -
#24828 [Asn->Csd]: round() function doesn't round !
ID: 24828 Updated by: edink@php.net Reported By: christophe dot bidaux at netcourrier dot com -Status: Assigned... -
#24828 [Opn->Asn]: round() function doesn't round !
ID: 24828 Updated by: iliaa@php.net Reported By: christophe dot bidaux at netcourrier dot com -Status: Open... -
#24828 [NEW]: round() function doesn't round !
From: christophe dot bidaux at netcourrier dot com Operating system: Windows 98SE PHP version: 4CVS-2003-07-27 (stable) PHP Bug... -
johannes@php.net #2
#40622 [Opn->Bgs]: round function
ID: 40622
Updated by: [email]johannes@php.net[/email]
Reported By: bruno dot boccara at d2b dot com
-Status: Open
+Status: Bogus
Bug Type: Math related
Operating System: windows 2003 Apache 2
PHP Version: 4.4.5
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:
[url]http://docs.sun.com/source/806-3568/ncg_goldberg.html[/url]
Thank you for your interest in PHP.
..
Previous Comments:
------------------------------------------------------------------------
[2007-02-24 21:36:47] bruno dot boccara at d2b dot com
Description:
------------
round function gives wrong value.
Please do not send me to
[url]http://docs.sun.com/source/806-3568/ncg_goldberg.html[/url], you have to
admit that this is a bug !!!!!
if not, php CANNOT be use in production site with mathematical
functions !!!
Reproduce code:
---------------
<?
// 140.25*(1-(34/100)) = 92.565
echo "formula = ". round(((140.25*(1-(34/100)))),2);echo "<br>";
echo "direct = ".round (92.565, 2);echo "<br>";
$valeur = 140.25*(1-(34/100));
echo "value = ".round($valeur,2);echo "<br>";
settype($valeur,"string");
settype($valeur,"float");
echo "value2 = ".round($valeur,2);
?>
Expected result:
----------------
formula = 92.57
direct = 92.57
value = 92.57
value2 = 92.57
Actual result:
--------------
formula = 92.56 // WRONG !
direct = 92.57
value = 92.56 // WRONG !
value2 = 92.57
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40622&edit=1[/url]
johannes@php.net Guest
-
bruno dot boccara at d2b dot com #3
#40622 [Bgs]: round function
ID: 40622
User updated by: bruno dot boccara at d2b dot com
Reported By: bruno dot boccara at d2b dot com
Status: Bogus
Bug Type: Math related
Operating System: windows 2003 Apache 2
PHP Version: 4.4.5
New Comment:
Did I send an email to a robot ??
Each user who ask this question get the same answer.
You should be ashaimed to do this. You know that this is a a very big
bug of PHP and no one is ready to resolve it !
This is not a way to do.
I'm very very desappointed.
For other users with this problem, you can do like me in the example to
avoid this problem. This will slow down a little the result. Use the
settype function to convert the number to string and then to float. I
did'n test it in all cases, but it seems to work.
Previous Comments:
------------------------------------------------------------------------
[2007-02-24 22:05:52] [email]johannes@php.net[/email]
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:
[url]http://docs.sun.com/source/806-3568/ncg_goldberg.html[/url]
Thank you for your interest in PHP.
..
------------------------------------------------------------------------
[2007-02-24 21:36:47] bruno dot boccara at d2b dot com
Description:
------------
round function gives wrong value.
Please do not send me to
[url]http://docs.sun.com/source/806-3568/ncg_goldberg.html[/url], you have to
admit that this is a bug !!!!!
if not, php CANNOT be use in production site with mathematical
functions !!!
Reproduce code:
---------------
<?
// 140.25*(1-(34/100)) = 92.565
echo "formula = ". round(((140.25*(1-(34/100)))),2);echo "<br>";
echo "direct = ".round (92.565, 2);echo "<br>";
$valeur = 140.25*(1-(34/100));
echo "value = ".round($valeur,2);echo "<br>";
settype($valeur,"string");
settype($valeur,"float");
echo "value2 = ".round($valeur,2);
?>
Expected result:
----------------
formula = 92.57
direct = 92.57
value = 92.57
value2 = 92.57
Actual result:
--------------
formula = 92.56 // WRONG !
direct = 92.57
value = 92.56 // WRONG !
value2 = 92.57
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40622&edit=1[/url]
bruno dot boccara at d2b dot com Guest



Reply With Quote

