Re: note 15001 added to function.pi.php

From: Date: Thu, 23 Aug 2001 21:12:11 +0000
Subject: Re: note 15001 added to function.pi.php
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-17049@lists.php.net to get a copy of this message
I added the following to your note: [Editor's note: for a cleaner and more sane solution to display of floating point numbers, see number_format() and/or round(), apparently the contributor of this note was not aware of those functions] --- stoneneedle@hushmail.com wrote: > I don't like this pi function. Perhaps in the next > version of PHP it could be modified such that you > can calculate pi out to a user-defined decimal > point. Such as echo pi(2); outputting "3.14" or > similar. Here's my code though: > > /* Calculate pi out to a certain decimal place - > limited to how far the original pi() command goes > out in the first place */ > > $pi = substr(pi(), 0,4); > > echo $pi; > > /* This example will output "3.14" > Note that the substr is at 0,4 > because it already counts the "3" > and the "." */ > > http://www.php.net/manual/en/function.pi.php > > > -- > PHP Notes Mailing List (http://www.php.net/) > To unsubscribe, e-mail: > php-notes-unsubscribe@lists.php.net > For additional commands, e-mail: > php-notes-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > ===== --- Jesus M. Castagnetto <jmcastagnetto@php.net> __________________________________________________ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/

« previous php.notes (#17049) next »