### Stats

80 Wednesday, January 4, 2017
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com

# BC Math (Binary Calculator)

## Introduction

The Binary Calculator can be used to calculate with numbers of any size and precision up to 2147483647-1 decimals, in string format. The Binary Calculator is more precise than the float calculation of PHP.

## Syntax

• string bcadd ( string \$left_operand , string \$right_operand [, int \$scale = 0 ] )
• int bccomp ( string \$left_operand , string \$right_operand [, int \$scale = 0 ] )
• string bcdiv ( string \$left_operand , string \$right_operand [, int \$scale = 0 ] )
• string bcmod ( string \$left_operand , string \$modulus )
• string bcmul ( string \$left_operand , string \$right_operand [, int \$scale = 0 ] )
• string bcpowmod ( string \$left_operand , string \$right_operand , string \$modulus [, int \$scale = 0 ] )
• bool bcscale ( int \$scale )
• string bcsqrt ( string \$operand [, int \$scale = 0 ] )
• string bcsub ( string \$left_operand , string \$right_operand [, int \$scale = 0 ] )

## Parameters

`left_operand`The left operand, as a string.
`right_operand`The right operand, as a string.
`scale`A optional parameter to set the number of digits after the decimal place in the result.
bccompCompare two arbitrary precision numbers.
`left_operand`The left operand, as a string.
`right_operand`The right operand, as a string.
`scale`A optional parameter to set the number of digits after the decimal place which will be used in the comparison.
bcdivDivide two arbitrary precision numbers.
`left_operand`The left operand, as a string.
`right_operand`The right operand, as a string.
`scale`A optional parameter to set the number of digits after the decimal place in the result.
bcmodGet modulus of an arbitrary precision number.
`left_operand`The left operand, as a string.
`modulus`The modulus, as a string.
bcmulMultiply two arbitrary precision numbers.
`left_operand`The left operand, as a string.
`right_operand`The right operand, as a string.
`scale`A optional parameter to set the number of digits after the decimal place in the result.
bcpowRaise an arbitrary precision number to another.
`left_operand`The left operand, as a string.
`right_operand`The right operand, as a string.
`scale`A optional parameter to set the number of digits after the decimal place in the result.
bcpowmodRaise an arbitrary precision number to another, reduced by a specified modulus.
`left_operand`The left operand, as a string.
`right_operand`The right operand, as a string.
`modulus`The modulus, as a string.
`scale`A optional parameter to set the number of digits after the decimal place in the result.
bcscaleSet default scale parameter for all bc math functions.
`scale`The scale factor.
bcsqrtGet the square root of an arbitrary precision number.
`operand`The operand, as a string.
`scale`A optional parameter to set the number of digits after the decimal place in the result.
bcsubSubtract one arbitrary precision number from another.
`left_operand`The left operand, as a string.
`right_operand`The right operand, as a string.
`scale`A optional parameter to set the number of digits after the decimal place in the result.

## Remarks

For all BC functions, if the `scale` parameter is not set, it defaults to 0, which will make all operations integer operations.