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

Breadcrumb

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

function NativeCalculator::doCmp

Compares two non-signed large numbers.

@psalm-return -1|0|1

2 calls to NativeCalculator::doCmp()
NativeCalculator::doDiv in vendor/brick/math/src/Internal/Calculator/NativeCalculator.php
Performs the division of two non-signed large integers.
NativeCalculator::doSub in vendor/brick/math/src/Internal/Calculator/NativeCalculator.php
Performs the subtraction of two non-signed large integers.

File

vendor/brick/math/src/Internal/Calculator/NativeCalculator.php, line 532

Class

NativeCalculator
Calculator implementation using only native PHP code.

Namespace

Brick\Math\Internal\Calculator

Code

private function doCmp(string $a, string $b) : int {
    $x = \strlen($a);
    $y = \strlen($b);
    $cmp = $x <=> $y;
    if ($cmp !== 0) {
        return $cmp;
    }
    return \strcmp($a, $b) <=> 0;
    // enforce -1|0|1
}

API Navigation

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