Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BigNumber.php

function BigNumber::sum

Returns the sum of the given values.

@psalm-pure

Parameters

BigNumber|int|float|string ...$values The numbers to add. All the numbers need to be convertible: to an instance of the class this method is called on.

Throws

\InvalidArgumentException If no values are given.

MathException If an argument is not valid.

File

vendor/brick/math/src/BigNumber.php, line 276

Class

BigNumber
Common interface for arbitrary-precision rational numbers.

Namespace

Brick\Math

Code

public static final function sum(BigNumber|int|float|string ...$values) : static {
    
    /** @var static|null $sum */
    $sum = null;
    foreach ($values as $value) {
        $value = static::of($value);
        $sum = $sum === null ? $value : self::add($sum, $value);
    }
    if ($sum === null) {
        throw new \InvalidArgumentException(__METHOD__ . '() expects at least one value.');
    }
    return $sum;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal