public static function Calculator::add in Price 8
Same name and namespace in other branches
- 3.x src/Calculator.php \Drupal\price\Calculator::add()
- 2.0.x src/Calculator.php \Drupal\price\Calculator::add()
- 2.x src/Calculator.php \Drupal\price\Calculator::add()
- 3.0.x src/Calculator.php \Drupal\price\Calculator::add()
Adds the second number to 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::add()
- Price::add in src/
Price.php - Adds the given price to the current price.
- PriceModified::add in src/
PriceModified.php - Adds the given price to the current price.
File
- src/
Calculator.php, line 30
Class
- Calculator
- Provides helpers for bcmath-based arithmetic.
Namespace
Drupal\priceCode
public static function add($first_number, $second_number, $scale = 6) {
self::assertNumberFormat($first_number);
self::assertNumberFormat($second_number);
$result = bcadd($first_number, $second_number, $scale);
return self::trim($result);
}