note 12405 deleted from function.log10 by pollita
| From: | pollita@php.net | Date: | Tue, 02 Sep 2003 02:23:20 +0000 |
| Subject: | note 12405 deleted from function.log10 by pollita | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-55452@lists.php.net to get a copy of this message | ||
Note Submitter: mnc-php@u.nu
----
PHP doesn't provide a mechanism to calculate logarithms with arbitrary bases, which at first
seems troubling since log base 2 is a fairly useful thing in binary operations. Fortunately,
it's easy to do using log10. Just divide log10 of your number by log10 of the base. So, for
instance, if you need to get the log base 2 of 32, you can do:
print log10(32)/log10(2);
and the answer will be 5.