private function doMul(string $a, string $b) : string
    {
        $x = \strlen($a);
        $y = \strlen($b);

        $maxDigits = \intdiv($this->maxDigits, 2);
        $complement = 10 ** $maxDigits;

        $result = '0';

        for ($i = $x - $maxDigits;; $i -= $maxDigits) {
            $blockALength = $maxDigits;

            if ($i < 0) {
                $blockALength += $i;
                $i = 0;
            }

            $blockA = (int) \substr($a, $i, $blockALength);

            $line = '';
            $carry = 0;

            for ($j = $y - $maxDigits;; $j -= $maxDigits) {
                $blockBLength = $maxDigits;

                if ($j < 0) {
                    $blockBLength += $j;
                    $j = 0;
                }

                $blockB = (int) \substr($b, $j, $blockBLength);

                $mul = $blockA * $blockB + $carry;
                $value = $mul % $complement;
                $carry = ($mul - $value) / $complement;

                $value = (string) $value;
                $value = \str_pad($value, $maxDigits, '0', STR_PAD_LEFT);

                $line = $value . $line;

                if ($j === 0) {
                    break;
                }
            }

            if ($carry !== 0) {
                $line = $carry . $line;
            }

            $line = \ltrim($line, '0');

            if ($line !== '') {
                $line .= \str_repeat('0', $x - $blockALength - $i);
                $result = $this->add($result, $line);
            }

            if ($i === 0) {
                break;
            }
        }

        return $result;
    }
private function doMul(string $a, string $b) : string
    {
        $x = \strlen($a);
        $y = \strlen($b);

        $maxDigits = \intdiv($this->maxDigits, 2);
        $complement = 10 ** $maxDigits;

        $result = '0';

        for ($i = $x - $maxDigits;; $i -= $maxDigits) {
            $blockALength = $maxDigits;

            if ($i < 0) {
                $blockALength += $i;
                $i = 0;
            }

            $blockA = (int) \substr($a, $i, $blockALength);

            $line = '';
            $carry = 0;

            for ($j = $y - $maxDigits;; $j -= $maxDigits) {
                $blockBLength = $maxDigits;

                if ($j < 0) {
                    $blockBLength += $j;
                    $j = 0;
                }

                $blockB = (int) \substr($b, $j, $blockBLength);

                $mul = $blockA * $blockB + $carry;
                $value = $mul % $complement;
                $carry = ($mul - $value) / $complement;

                $value = (string) $value;
                $value = \str_pad($value, $maxDigits, '0', STR_PAD_LEFT);

                $line = $value . $line;

                if ($j === 0) {
                    break;
                }
            }

            if ($carry !== 0) {
                $line = $carry . $line;
            }

            $line = \ltrim($line, '0');

            if ($line !== '') {
                $line .= \str_repeat('0', $x - $blockALength - $i);
                $result = $this->add($result, $line);
            }

            if ($i === 0) {
                break;
            }
        }

        return $result;
    }
private function doMul ( string $ a , string $ b ) : string { $ x = \ strlen ( $ a ) ; $ y = \ strlen ( $ b ) ; $ maxDigits = \ intdiv ( $ this -> maxDigits , 2 ) ; $ complement = 10 ** $ maxDigits ; $ result = '0' ; for ( $ i = $ x - $ maxDigits ; ; $ i -= $ maxDigits ) { $ blockALength = $ maxDigits ; if ( $ i < 0 ) { $ blockALength += $ i ; $ i = 0 ; } $ blockA = ( int ) \ substr ( $ a , $ i , $ blockALength ) ; $ line = '' ; $ carry = 0 ; for ( $ j = $ y - $ maxDigits ; ; $ j -= $ maxDigits ) { $ blockBLength = $ maxDigits ; if ( $ j < 0 ) { $ blockBLength += $ j ; $ j = 0 ; } $ blockB = ( int ) \ substr ( $ b , $ j , $ blockBLength ) ; $ mul = $ blockA * $ blockB + $ carry ; $ value = $ mul % $ complement ; $ carry = ( $ mul - $ value ) / $ complement ; $ value = ( string ) $ value ; $ value = \ str_pad ( $ value , $ maxDigits , '0' , STR_PAD_LEFT ) ; $ line = $ value . $ line ; if ( $ j === 0 ) { break ; } } if ( $ carry !== 0 ) { $ line = $ carry . $ line ; } $ line = \ ltrim ( $ line , '0' ) ; if ( $ line !== '' ) { $ line .= \ str_repeat ( '0' , $ x - $ blockALength - $ i ) ; $ result = $ this -> add ( $ result , $ line ) ; } if ( $ i === 0 ) { break ; } } return $ result ; }
Performs the multiplication of two non-signed large integers.

@param string $a The first operand.
@param string $b The second operand.

@return string
Performs the multiplication of two non - signed large integers .