lib/bcmath.js
function bcadd(left_operand, right_operand, scale) {
    var first, second, result;

    if (typeof(scale) == 'undefined') {
        scale = libbcmath.scale;
    }
    scale   = ((scale < 0) ? 0 : scale);

    // create objects
    first   = libbcmath.bc_init_num();
    second  = libbcmath.bc_init_num();
    result  = libbcmath.bc_init_num();

    first   = libbcmath.php_str2num(left_operand.toString());
    second  = libbcmath.php_str2num(right_operand.toString());

    // normalize arguments to same scale.
    if (first.n_scale > second.n_scale) second.setScale(first.n_scale);
    if (second.n_scale > first.n_scale) first.setScale(second.n_scale);

    result  = libbcmath.bc_add(first, second, scale);

    if (result.n_scale > scale) {
        result.n_scale = scale;
    }

    return result.toString();
}
function bcadd(left_operand, right_operand, scale) {
    var first, second, result;

    if (typeof(scale) == 'undefined') {
        scale = libbcmath.scale;
    }
    scale   = ((scale < 0) ? 0 : scale);

    // create objects
    first   = libbcmath.bc_init_num();
    second  = libbcmath.bc_init_num();
    result  = libbcmath.bc_init_num();

    first   = libbcmath.php_str2num(left_operand.toString());
    second  = libbcmath.php_str2num(right_operand.toString());

    // normalize arguments to same scale.
    if (first.n_scale > second.n_scale) second.setScale(first.n_scale);
    if (second.n_scale > first.n_scale) first.setScale(second.n_scale);

    result  = libbcmath.bc_add(first, second, scale);

    if (result.n_scale > scale) {
        result.n_scale = scale;
    }

    return result.toString();
}
function bcadd ( left_operand , right_operand , scale ) { var first , second , result ; if ( typeof ( scale ) == 'undefined' ) { scale = libbcmath . scale ; } scale = ( ( scale < 0 ) ? 0 : scale ) ; // create objects first = libbcmath . bc_init_num ( ) ; second = libbcmath . bc_init_num ( ) ; result = libbcmath . bc_init_num ( ) ; first = libbcmath . php_str2num ( left_operand . toString ( ) ) ; second = libbcmath . php_str2num ( right_operand . toString ( ) ) ; // normalize arguments to same scale. if ( first . n_scale > second . n_scale ) second . setScale ( first . n_scale ) ; if ( second . n_scale > first . n_scale ) first . setScale ( second . n_scale ) ; result = libbcmath . bc_add ( first , second , scale ) ; if ( result . n_scale > scale ) { result . n_scale = scale ; } return result . toString ( ) ; }
PHP Implementation of the libbcmath functions

Designed to replicate the PHP functions exactly.
Also includes new function: bcround
 
bcadd - Add two arbitrary precision numbers
Sums left_operand and right_operand.

@param string left_operand       The left operand, as a string
@param string right_operand      The right operand, as a string.
@param int [scale]               The optional parameter is used to set the number of digits after the decimal place in the result. You can also set the global scale for all functions by using bcscale()
@return string
PHP Implementation of the libbcmath functions