You are here

public static function Calculator::compare in Physical Fields 8

Compares the first number to 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

int 0 if both numbers are equal, 1 if the first one is greater, -1 otherwise.

5 calls to Calculator::compare()
Calculator::ceil in src/Calculator.php
Calculates the next highest whole value of a number.
Calculator::floor in src/Calculator.php
Calculates the next lowest whole value of a number.
Calculator::round in src/Calculator.php
Rounds the given number.
Measurement::compareTo in src/Measurement.php
Compares the current measurement with the given one.
Measurement::isZero in src/Measurement.php
Gets whether the current measurement is zero.

File

src/Calculator.php, line 219

Class

Calculator
Provides helpers for bcmath-based arithmetic.

Namespace

Drupal\physical

Code

public static function compare($first_number, $second_number, $scale = 16) {
  self::assertNumberFormat($first_number);
  self::assertNumberFormat($second_number);
  return bccomp($first_number, $second_number, $scale);
}