Bug #52405 [Opn->Bgs]: Inaccurate Pi calculation
| From: | aharvey@php.net | Date: | Thu, 22 Jul 2010 13:50:44 +0000 |
| Subject: | Bug #52405 [Opn->Bgs]: Inaccurate Pi calculation | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-152615@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52405&edit=1
ID: 52405
Updated by: aharvey@php.net
Reported by: chrisbabar at hotmail dot com
Summary: Inaccurate Pi calculation
-Status: Open
+Status: Bogus
Type: Bug
Package: *Math Functions
Operating System: Ubuntu 10.04 LTS
PHP Version: 5.3.2
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:
------------------------------------------------------------------------
[2010-07-22 15:44:47] chrisbabar at hotmail dot com
Description:
------------
PHP seems to calculate pi incorrectly after 15 decimal places when
calling the pi() function. I have used http://en.wikipedia.org/wiki/Pi
as a reference for the correct value of pi.
Test script:
---------------
<?php
ini_set("precision", 24);
echo pi();
?>
Expected result:
----------------
3.14159265358979323846264
Actual result:
--------------
3.14159265358979311599796
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52405&edit=1