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!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
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!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
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 . ?
I am fairly sure that you have to use BCMath for this:
http://www.php.net/manual/en/ref.bc.php
Give it a go and see what happens! :)
but my server configure don't have bcmath enabled, is there any other way to
do so?
Torgny Bjers [EMAIL PROTECTED] wrote:[EMAIL PROTECTED]
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 . ?
Wong HoWang schrieb:
but my server configure don't have bcmath enabled, is there any other way to
do so?
Since the internal routines of PHP have limited precision, you these
options:
- Find a way to activate bcmath (not likely to happen on a shared
hosting account)
- Find an external program
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.
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 [EMAIL PROTECTED]
wrote:[EMAIL PROTECTED]
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
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
9 matches
Mail list logo