Skip to content

Latest commit

 

History

History
75 lines (59 loc) · 3.28 KB

README.md

File metadata and controls

75 lines (59 loc) · 3.28 KB

BC::math

Software License Gitter

Latest Version Build Status Total Downloads

PHP bcmath as a static class, with several enhancements.

Installation

Use Composer:

composer require danhunsaker/bcmath

Usage

Usage is nearly identical to the bcmath extension functions. The main difference is that the bc prefix is replaced by the Danhunsaker\BC class name (which you can easily alias in your project(s) via use Danhunsaker\BC).

In other words:

There are also some additional convenience methods available, that aren't present in the extension:

  • BC::epow() raises e to the argument's power.
  • BC::fact() calculates the factorial of the argument.
  • BC::ln() gives the natural logarithm of the argument.
  • BC::log() gives the base 10 logarithm of the argument (uses ln $val/ln 10).
  • BC::max() returns the largest value in an array (the first argument).
  • BC::min() returns the smallest value in an array (the first argument).
  • BC::modfrac() behaves exactly like BC::mod(), except it will return the fractional part of any remainder as well as the integer part.
  • BC::powfrac() supports fractional exponents, allowing roots other than the square to be calculated.
  • BC::root() is a complement to BC::powfrac(), and is in fact just a convenience wrapper for it.
  • BC::round() rounds a value to a given scale.

Contributions

Contributions are welcome at any time on GitHub.

Security issues should be reported directly to Dan Hunsaker via email.