bcscale

string bcscale(int scale) 
scale Number of decimal places to return

Sets scale.

Returns:

Always TRUE

Description:

bcscale() can be used with all BC math functions. It sets the default number of decimal places to return for all BC math functions if the scale is not passed as a parameter to the function. Naturally, if the number is defined in the function, the value in bcscale() is overridden.

Version:

Existing since version 3.0

Example:

Set scale to two decimal places
$num1 = "9912343.34546"; 
$num2 = "1"; 
echo bcmul($num1, $num2) . "\n"; 
// 2 decimal places 
bcscale(2); 
echo bcmul($num1, $num2); 

Output: 
9912343 
9912343.34 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.