lib/bcmath.js
function bcdiv(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_divide(first, second, scale);
    if (result === -1) {
        // error
        throw new Error(11, "(BC) Division by zero");
    }
    if (result.n_scale > scale) {
        result.n_scale = scale;
    }
    return result.toString();
}
function bcdiv(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_divide(first, second, scale);
    if (result === -1) {
        // error
        throw new Error(11, "(BC) Division by zero");
    }
    if (result.n_scale > scale) {
        result.n_scale = scale;
    }
    return result.toString();
}
function bcdiv ( 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_divide ( first , second , scale ) ; if ( result === - 1 ) { // error throw new Error ( 11 , "(BC) Division by zero" ) ; } if ( result . n_scale > scale ) { result . n_scale = scale ; } return result . toString ( ) ; }
bcdiv - Divide two arbitrary precision numbers

@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                   The result as a string
bcdiv - Divide two arbitrary precision numbers