BC Extra is a library of functions that work in PHP's BC Math. BC Math allows arbitrary precision arithmetic on values represented as strings, but only includes basic mathematical functions. This library adds several additional functions:

- Factorial (x!)
- Natural log (ln x)
- Exponential (e
^{x}) - Power-of (a
^{x}) - Pi
- Sine
- Cosine
- Tangent
- Arcsine
- Arccosine
- Arctangent
- Random number (between 0 and 1)

The functions of this library are pretty straight forward. Detailed documentation is available online, generated from the source code using phpDocumentor. The documentation can be recreated from the source if needed.

Leave a comment if you find this library useful.

Hi Andrew!

First of all, thank you for sharing such a fantastic library. I've been working with high precise numbers in PHP for the last months, and your library is impressive fast when compared to other libraries with the same purpose. Congratulations!

I'm writing because I found some issues when computing the power of numbers using fractional exponents. The algorithm relies on the formula x ^ y = exp(y * log (x)) to calculate exponentiation. My guess is that the problem is related to estimating the scale needed for precisely computing the result up to a given scale.

I'm trying to fix it because the application I'm working on requires accurate results. If you have any guess about how to compute it, please let me know, it will help a lot.

Example:

// Expected: 310472657364304703.652201517571826032805777140298

// Result: 310472657364304703.652201517571826028599733563396

bcpow('9223372036854775807', '0.9223372036854775807', 25)

Thank you again.

- Marcos

BC Extra is is free, open-source software released under the GNU license.

BC Extra is written and maintained by Andrew Que. To get in touch with Andrew Que, visit his contact page.

(C) Copyright 2015 by Andrew Que.