PHP | bcdiv() Function Last Updated : 19 Apr, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The bcdiv() function in PHP is an inbuilt function and is used to divide two arbitrary precision numbers. This function accepts two arbitrary precision numbers as strings and returns the division of the two numbers after scaling the result to a specified precision. Syntax: string bcdiv ( $num_str1, $num_str2, $scaleVal) Parameters: This function accepts three parameters as shown in the above syntax and explained below: $num_str1: This parameter is of string type and represents the dividend. This parameter is mandatory. $num_str2: This parameter is of string type and represents the divisor. This parameter is mandatory. $scaleVal: This parameter is of int type and is optional. This parameter tells the number of digits that will appear after the decimal in the result of division. It's default value is zero. Return Value: This function returns the division of the number $num_str1 by $num_str2 as string. Examples: Input: $num_str1 = 11.222, $num_str2 = 3 Output: 3 Since the parameter $scaleVal is not specified so no digits after decimal is appeared in the result after division. Input: $num_str1 = 11.222, $num_str2 = 3, $scaleVal = 4 Output: 3.7406 Below programs illustrate the bcdiv() function in PHP : Program 1: php <?php // PHP program to illustrate bcdiv() function // input numbers $num_str1 = "11.222"; // dividend $num_str2 = "3"; // divisor // calculates the division of // the two numbers when $scaleVal is // not specified $res = bcdiv($num_str1, $num_str2); echo $res; ?> Output: 3 Program 2: php <?php // PHP program to illustrate bcdiv() function // input numbers $num_str1 = "11.222"; // dividend $num_str2 = "3"; // divisor // scale value $scaleVal = 4; // calculates the division of the two // numbers when $scaleVal is specified $res = bcdiv($num_str1, $num_str2, $scaleVal); echo $res; ?> Output: 3.7406 Reference: http://php.net/manual/en/function.bcdiv.php Comment More infoAdvertise with us Next Article PHP ceil( ) Function B barykrg Follow Improve Article Tags : Web Technologies PHP PHP-bc Similar Reads PHP fdiv() Function The fdiv() is an inbuilt PHP function that returns the result of a division of 2 numbers(in accordance with IEEE 754). The NaN will never == or === for any value while doing the comparison, even including itself. Syntax: fdiv(float $num1, float $num2): floatParameters: This function accepts 2 parame 1 min read PHP | bcmod() Function The bcmod() function in PHP is an inbuilt function and is used to calculate modulus of an arbitrary precision numbers. This function accepts an arbitrary precision number and returns the modulus of that number after scaling the result to a specified precision. Syntax: string bcadd ( $dividend, $modu 2 min read PHP | bcadd() Function The bcadd() function in PHP is an inbuilt function and is used to add two arbitrary precision numbers. This function accepts two arbitrary precision numbers as strings and returns the addition of the two numbers after scaling the result to a specified precision. Syntax: string bcadd ( $num_str1, $nu 2 min read PHP ceil( ) Function We have often used the ceiling function in mathematical problems to round up a decimal number to next greater integral value. PHP provides us with a built-in function ceil() to perform such operation. The ceil() function is a built-in function in PHP and is used to round a number to the nearest grea 1 min read PHP | bcpow() Function The bcpow() function in PHP is an inbuilt function and is used to calculate the value of an arbitrary precision base number raised to another exponent number. This function accepts two arbitrary precision numbers as strings and returns the base number raised to exponent after scaling the result to a 2 min read PHP | bcmul() Function The bcmul() function in PHP is an inbuilt function and is used to multiply two arbitrary precision numbers. This function accepts two arbitrary precision numbers as strings and returns the multiplication of the two numbers after scaling the result to a specified precision. Syntax: string bcmul ( $nu 2 min read Like