|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-12-20 21:43 UTC] sandaq at gmail dot com
Description:
------------
php doesn't calculate the correct value of pi
Test script:
---------------
php-cli -r 'ini_set('precision','100'); echo pi();'
or
<?
ini_set('precision','100');
echo pi()."\n"; exit;
?>
Expected result:
----------------
3.141592653589793238462643383279502884197169399375
Actual result:
--------------
3.141592653589793115997963468544185161590576171875
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 05:00:01 2025 UTC |
Nothing to see here, read about floating point numbers and their rounding error. In[9]:= Pi \ //SetPrecision[#,MachinePrecision]& \ //SetPrecision[#,Infinity]& \ //N[#,100]& Out[9]= 3.1415926535897931159979634685441851615905761718750000000000000000000\ > 00000000000000000000000000000000