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

Breadcrumb

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

function BigNumber::of

Creates a BigNumber of the given value.

The concrete return type is dependent on the given value, with the following rules:

  • BigNumber instances are returned as is
  • integer numbers are returned as BigInteger
  • floating point numbers are converted to a string then parsed as such
  • strings containing a `/` character are returned as BigRational
  • strings containing a `.` character or using an exponential notation are returned as BigDecimal
  • strings containing only digits with an optional leading `+` or `-` sign are returned as BigInteger

@psalm-pure

Throws

NumberFormatException If the format of the number is not valid.

DivisionByZeroException If the value represents a rational number with a denominator of zero.

5 calls to BigNumber::of()
BigDecimal::compareTo in vendor/brick/math/src/BigDecimal.php
Compares this number to the given one.
BigInteger::compareTo in vendor/brick/math/src/BigInteger.php
Compares this number to the given one.
BigNumber::max in vendor/brick/math/src/BigNumber.php
Returns the maximum of the given values.
BigNumber::min in vendor/brick/math/src/BigNumber.php
Returns the minimum of the given values.
BigNumber::sum in vendor/brick/math/src/BigNumber.php
Returns the sum of the given values.

File

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

Class

BigNumber
Common interface for arbitrary-precision rational numbers.

Namespace

Brick\Math

Code

public static final function of(BigNumber|int|float|string $value) : static {
    $value = self::_of($value);
    if (static::class === BigNumber::class) {
        // https://github.com/vimeo/psalm/issues/10309
        assert($value instanceof static);
        return $value;
    }
    return static::from($value);
}

API Navigation

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