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

Breadcrumb

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

function BigInteger::toBase

Returns a string representation of this number in the given base.

The output will always be lowercase for bases greater than 10.

Throws

\InvalidArgumentException If the base is out of range.

1 call to BigInteger::toBase()
BigInteger::getBitLength in vendor/brick/math/src/BigInteger.php
Returns the number of bits in the minimal two's-complement representation of this BigInteger, excluding a sign bit.

File

vendor/brick/math/src/BigInteger.php, line 918

Class

BigInteger
An arbitrary-size integer.

Namespace

Brick\Math

Code

public function toBase(int $base) : string {
    if ($base === 10) {
        return $this->value;
    }
    if ($base < 2 || $base > 36) {
        throw new \InvalidArgumentException(\sprintf('Base %d is out of range [2, 36]', $base));
    }
    return Calculator::get()->toBase($this->value, $base);
}

API Navigation

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