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

Breadcrumb

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

function NativeCalculator::pad

Pads the left of one of the given numbers with zeros if necessary to make both numbers the same length.

The numbers must only consist of digits, without leading minus sign.

Return value

array{string, string, int}

2 calls to NativeCalculator::pad()
NativeCalculator::doAdd in vendor/brick/math/src/Internal/Calculator/NativeCalculator.php
Performs the addition 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 553

Class

NativeCalculator
Calculator implementation using only native PHP code.

Namespace

Brick\Math\Internal\Calculator

Code

private function pad(string $a, string $b) : array {
    $x = \strlen($a);
    $y = \strlen($b);
    if ($x > $y) {
        $b = \str_repeat('0', $x - $y) . $b;
        return [
            $a,
            $b,
            $x,
        ];
    }
    if ($x < $y) {
        $a = \str_repeat('0', $y - $x) . $a;
        return [
            $a,
            $b,
            $y,
        ];
    }
    return [
        $a,
        $b,
        $x,
    ];
}

API Navigation

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