What potential pitfalls should be considered when using bcdiv and bcmul functions in PHP for calculations?

When using the bcdiv and bcmul functions in PHP for calculations, potential pitfalls to consider include rounding errors due to floating-point precision limitations. To avoid this issue, it is recommended to set the scale parameter explicitly to match the desired precision.

// Set the scale parameter to avoid rounding errors
$div_result = bcdiv('10', '3', 2); // Divides 10 by 3 with a precision of 2 decimal places
$mul_result = bcmul('2.5', '3', 2); // Multiplies 2.5 by 3 with a precision of 2 decimal places

echo $div_result; // Output: 3.33
echo $mul_result; // Output: 7.50