Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
communitycreator

What is bcdiv in PHP?

Sheza Naveed

bcdiv is a function in PHP that computes the division of arbitrary precision numbers.

Syntax

bcdiv(string $num1, string $num2, int $scale = null): string

Parameters

  • num1 - variable of type string.

num1 is a dividend.

  • num2 - variable of type string.

num2 is a divisor.

  • scale - variable of type int. This is an optional parameter. scale is used to set the number of digits after the decimal place in the result. The default value of scale is 0.

Return value

The function returns the num1/num2. The value returned is of type string.

null is returned if num2 is zero.

Code

<?php
$num1 = '105';
$num2 = '6.55957';

echo bcdiv($num1, $num2, 3);
?>

Expected output

16.007

RELATED TAGS

php
communitycreator
RELATED COURSES

View all Courses

Keep Exploring