public static function Calculator::subtract in Price 3.0.x
Same name and namespace in other branches
- 8 src/Calculator.php \Drupal\price\Calculator::subtract()
- 3.x src/Calculator.php \Drupal\price\Calculator::subtract()
- 2.0.x src/Calculator.php \Drupal\price\Calculator::subtract()
- 2.x src/Calculator.php \Drupal\price\Calculator::subtract()
Subtracts the second number from the first number.
Parameters
string $first_number: The first number.
string $second_number: The second number.
int $scale: The maximum number of digits after the decimal place. Any digit after $scale will be truncated.
Return value
string The result.
2 calls to Calculator::subtract()
- Price::subtract in src/
Price.php - Subtracts the given price from the current price.
- PriceModified::subtract in src/
PriceModified.php - Subtracts the given price from the current price.
File
- src/
Calculator.php, line 51
Class
- Calculator
- Provides helpers for bcmath-based arithmetic.
Namespace
Drupal\priceCode
public static function subtract($first_number, $second_number, $scale = 6) {
self::assertNumberFormat($first_number);
self::assertNumberFormat($second_number);
$result = bcsub($first_number, $second_number, $scale);
return self::trim($result);
}