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\CalculatorCode
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,
];
}