You are here

public static function Calculator::multiply in Price 3.0.x

Same name and namespace in other branches
  1. 8 src/Calculator.php \Drupal\price\Calculator::multiply()
  2. 3.x src/Calculator.php \Drupal\price\Calculator::multiply()
  3. 2.0.x src/Calculator.php \Drupal\price\Calculator::multiply()
  4. 2.x src/Calculator.php \Drupal\price\Calculator::multiply()

Multiplies 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.

4 calls to Calculator::multiply()
Price::convert in src/Price.php
Converts the current price to the given currency.
Price::multiply in src/Price.php
Multiplies the current price by the given number.
PriceModified::convert in src/PriceModified.php
Converts the current price to the given currency.
PriceModified::multiply in src/PriceModified.php
Multiplies the current price by the given number.

File

src/Calculator.php, line 72

Class

Calculator
Provides helpers for bcmath-based arithmetic.

Namespace

Drupal\price

Code

public static function multiply($first_number, $second_number, $scale = 6) {
  self::assertNumberFormat($first_number);
  self::assertNumberFormat($second_number);
  $result = bcmul($first_number, $second_number, $scale);
  return self::trim($result);
}