Reply to Re: [PHP] Help: Get the value of pi up to 200+ digits? -- oops

Your name:

Reply:


Posted by Steve Edberg on 09/01/05 21:55

Oops...I didn't see the earlier message that BC functions were not enabled
on your server. So, I'd have to concur with Oliver Grätz's suggestions, and
add some of my own:

- can you change hosts?
- are you allowed to install software in your own directory? You
may be able to compile & install your own version of PHP and call it via CGI.

steve, again.


Hi -

The 'precision' ini value refers, I believe, only to float numbers, not
BC_math numbers (which are stored as strings). I believe the bcmath.scale
parameter is the one you need. It can be set via ini_set or bcscale() -

http://php.he.net/manual/en/function.bcscale.php

Perhaps you could tell us *why* you need pi to 200 digits. If it's just for
display, I'd simply define it as a string somewhere in your program:

define('PI_LOOOOOONNNG', '3.1415927...........8468');

However, I would guess that doing math using the BC functions at that
precision would be extremely slow. Going to a dedicated math package like
MATLAB or Mathematica or something might be more appropriate.

steve


At 08:57 AM 9/1/2005, Wong HoWang wrote:
>Dear Jordan,
>
>I know what you mean. But you may try this one and you will know:
><?php
>ini_set('precision',200);
>echo pi();
>?>
>the result is the same as 16!!!
>
>So that's why I ask this question! I am not stupid like that!
>
>Please help, thx!
>
>
>"Jordan Miller" <jmil@hymiegladstone.com>
>wrote:534D8D52-751D-45B6-9B49-DD9FA136C727@hymiegladstone.com...
> > http://us3.php.net/manual/en/ini.core.php#ini.precision
> >
> > precision sets the number of significant digits, *NOT* the number of
> > digits displayed after the decimal point.
> >
> > If you want to get pi out to 16 decimal places you need a precision of
> > *17* because the beginning 3 is a significant digit.
> >
> > Your code does exactly this, displaying pi with 15 decimal places.
> >
> > Jordan
> >
> >
> >
> > On Sep 1, 2005, at 8:06 AM, Wong HoWang wrote:
> >
> >> Dear all,
> >>
> >> I'm trying to do like this but failed:
> >>
> >> <?php
> >> ini_set('precision',16);
> >> echo pi();
> >> ?>
> >>
> >> How can I get more digits after . ?
> >>
> >> Can anyone help? Thx!
> >>

+------------------------------------------------------------------------+
| Steve Edberg sbedberg@ucdavis.edu |
| Database/Programming/SysAdmin (530)754-9127 |
| UC Davis Genome Center http://pgfsun.ucdavis.edu/ |
+---------------------- Gort, Klaatu barada nikto! ----------------------+

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация