public static function Calculator::compare in Price 8
Same name and namespace in other branches
- 3.x src/Calculator.php \Drupal\price\Calculator::compare()
- 2.0.x src/Calculator.php \Drupal\price\Calculator::compare()
- 2.x src/Calculator.php \Drupal\price\Calculator::compare()
- 3.0.x src/Calculator.php \Drupal\price\Calculator::compare()
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.
7 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.
- Price::compareTo in src/
Price.php - Compares the current price with the given price.
- Price::isZero in src/
Price.php - Gets whether the current price is zero.
File
- src/
Calculator.php, line 217
Class
- Calculator
- Provides helpers for bcmath-based arithmetic.
Namespace
Drupal\priceCode
public static function compare($first_number, $second_number, $scale = 6) {
self::assertNumberFormat($first_number);
self::assertNumberFormat($second_number);
return bccomp($first_number, $second_number, $scale);
}