You are here

public static function Calculator::divide in Physical Fields 8

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.

3 calls to Calculator::divide()
Measurement::convert in src/Measurement.php
Converts the current measurement to a new unit.
Measurement::divide in src/Measurement.php
Divides the current measurement by the given number.
Temperature::convert in src/Temperature.php
Converts the current temperature measurement to a new unit.

File

src/Calculator.php, line 95

Class

Calculator
Provides helpers for bcmath-based arithmetic.

Namespace

Drupal\physical

Code

public static function divide($first_number, $second_number, $scale = 16) {
  self::assertNumberFormat($first_number);
  self::assertNumberFormat($second_number);
  $result = bcdiv($first_number, $second_number, $scale);
  return self::trim($result);
}