bcsub
string bcsub(string left_operand, string right_operand, [int scale])
left_operand | Number to subtract from |
right_operand | Number to subtract |
scale | Number of decimal places to return |
Subtracts right operand from left operand.
Returns:
Subtracted number
Description:
bcsub() subtracts the second number from the first number and returns the result, formatted with a specified number of decimal places (optional).
Version:
Existing since version 3.0
Example:
Subtract two large numbers
$num1 = "9912343.34546";
$num2 = "34546.9912343";
echo bcsub($num1, $num2, 3);
Output:
9877796.354
|
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.