bcadd

This function is meant to be a drop-in replacement for those people who don’t have bcmath functionality in their PHP distribution.  It probably has problems, and the best solution is to build yourself a version with bcmath support.  Barring this, you can use this hack.  (Jeff)

A regex for exponential numbers is [-+]?([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?

Summary
This function is meant to be a drop-in replacement for those people who don’t have bcmath functionality in their PHP distribution.
Provides bcadd functionality (from bcmath extension) without having to load bcmath PHP extension.

Functions

bcadd

function bcadd ($left,
$right,
$scale)

Provides bcadd functionality (from bcmath extension) without having to load bcmath PHP extension.

Parameters

$leftFirst number to add.
$rightSecond number to add.
$scaleNumber of digits of precision desired after the decimal point.  0 will produce an integer.

Returns

left and right added together with a precision of scale.

function bcadd ($left,
$right,
$scale)
Provides bcadd functionality (from bcmath extension) without having to load bcmath PHP extension.