You are here

public static function Calculator::multiply in Commerce Core 8.2

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.

7 calls to Calculator::multiply()
BuyXGetY::buildConfigurationForm in modules/promotion/src/Plugin/Commerce/PromotionOffer/BuyXGetY.php
Form constructor.
BuyXGetYTest::setUp in modules/promotion/tests/src/Kernel/Plugin/Commerce/PromotionOffer/BuyXGetYTest.php
CalculatorTest::testArithmetic in modules/price/tests/src/Unit/CalculatorTest.php
@covers ::add @covers ::subtract @covers ::multiply @covers ::divide @covers ::compare @covers ::trim
MinorUnitsConverter::toMinorUnits in modules/price/src/MinorUnitsConverter.php
Converts the given amount to its minor units.
PercentageOffTrait::buildConfigurationForm in modules/promotion/src/Plugin/Commerce/PromotionOffer/PercentageOffTrait.php

... See full list

File

modules/price/src/Calculator.php, line 72

Class

Calculator
Provides helpers for bcmath-based arithmetic.

Namespace

Drupal\commerce_price

Code

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