You are here

public static function Calculator::add in Physical Fields 8

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()
Measurement::add in src/Measurement.php
Adds the given measurement to the current one.
Temperature::convert in src/Temperature.php
Converts the current temperature measurement to a new unit.

File

src/Calculator.php, line 32

Class

Calculator
Provides helpers for bcmath-based arithmetic.

Namespace

Drupal\physical

Code

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