public static function Calculator::divide in Price 2.x
Same name and namespace in other branches
- 8 src/Calculator.php \Drupal\price\Calculator::divide()
- 3.x src/Calculator.php \Drupal\price\Calculator::divide()
- 2.0.x src/Calculator.php \Drupal\price\Calculator::divide()
- 3.0.x src/Calculator.php \Drupal\price\Calculator::divide()
Divides the first number by the second 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::divide()
- MinorUnitsConverter::fromMinorUnits in src/
MinorUnitsConverter.php - Converts an amount in "minor unit" to a decimal amount.
- Price::divide in src/
Price.php - Divides the current price by the given number.
File
- src/
Calculator.php, line 93
Class
- Calculator
- Provides helpers for bcmath-based arithmetic.
Namespace
Drupal\priceCode
public static function divide(string $first_number, string $second_number, int $scale = 6) : string {
self::assertNumberFormat($first_number);
self::assertNumberFormat($second_number);
$result = bcdiv($first_number, $second_number, $scale);
return self::trim($result);
}