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

Breadcrumb

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

function BigDecimal::compareTo

Overrides BigNumber::compareTo

File

vendor/brick/math/src/BigDecimal.php, line 538

Class

BigDecimal
Immutable, arbitrary-precision signed decimal numbers.

Namespace

Brick\Math

Code

public function compareTo(BigNumber|int|float|string $that) : int {
    $that = BigNumber::of($that);
    if ($that instanceof BigInteger) {
        $that = $that->toBigDecimal();
    }
    if ($that instanceof BigDecimal) {
        [
            $a,
            $b,
        ] = $this->scaleValues($this, $that);
        return Calculator::get()->cmp($a, $b);
    }
    return -$that->compareTo($this);
}

API Navigation

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