You are here

public static function Calculator::ceil in Price 2.x

Same name and namespace in other branches
  1. 8 src/Calculator.php \Drupal\price\Calculator::ceil()
  2. 3.x src/Calculator.php \Drupal\price\Calculator::ceil()
  3. 2.0.x src/Calculator.php \Drupal\price\Calculator::ceil()
  4. 3.0.x src/Calculator.php \Drupal\price\Calculator::ceil()

Calculates the next highest whole value of a number.

Parameters

string $number: A numeric string value.

Return value

string The result.

File

src/Calculator.php, line 109

Class

Calculator
Provides helpers for bcmath-based arithmetic.

Namespace

Drupal\price

Code

public static function ceil(string $number) : string {
  if (self::compare($number, 0) == 1) {
    $result = bcadd($number, '1', 0);
  }
  else {
    $result = bcadd($number, '0', 0);
  }
  return $result;
}