# PHP 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.
{"ft_lang_label":"__label__en","ft_lang_prob":0.5523603,"math_prob":0.99254745,"size":2517,"snap":"2022-27-2022-33","text_gpt3_token_len":593,"char_repetition_ratio":0.21130124,"word_repetition_ratio":0.6025,"special_character_ratio":0.21493842,"punctuation_ratio":0.13461539,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9763455,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-13T16:21:40Z\",\"WARC-Record-ID\":\"<urn:uuid:230bed77-5690-4a96-9965-cd697980b796>\",\"Content-Length\":\"76190\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:ad4f8ae3-bb2d-4119-89a1-1de4ebea90ec>\",\"WARC-Concurrent-To\":\"<urn:uuid:1ecf14fd-3446-488e-bea2-ef862703c7b4>\",\"WARC-IP-Address\":\"40.83.160.29\",\"WARC-Target-URI\":\"https://riptutorial.com/php/topic/8550/bc-math--binary-calculator-\",\"WARC-Payload-Digest\":\"sha1:IAHQDFBPNHCHPOSBERCCGSOMJ6WDJC54\",\"WARC-Block-Digest\":\"sha1:DZQ3KU67OMZIOZP7DU26XKROKLKOZ6EO\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882571959.66_warc_CC-MAIN-20220813142020-20220813172020-00424.warc.gz\"}"}