public function ParagonIE_Sodium_Core32_Int64::shiftLeft in Automatic Updates 7
Same name and namespace in other branches
- 8 vendor/paragonie/sodium_compat/src/Core32/Int64.php \ParagonIE_Sodium_Core32_Int64::shiftLeft()
Parameters
int $c:
Return value
Throws
SodiumException
TypeError
1 call to ParagonIE_Sodium_Core32_Int64::shiftLeft()
- ParagonIE_Sodium_Core32_Int64::shiftRight in vendor/
paragonie/ sodium_compat/ src/ Core32/ Int64.php
File
- vendor/
paragonie/ sodium_compat/ src/ Core32/ Int64.php, line 679
Class
- ParagonIE_Sodium_Core32_Int64
- Class ParagonIE_Sodium_Core32_Int64
Code
public function shiftLeft($c = 0) {
ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1);
/** @var int $c */
$c = (int) $c;
$return = new ParagonIE_Sodium_Core32_Int64();
$return->unsignedInt = $this->unsignedInt;
$c &= 63;
if ($c >= 16) {
if ($c >= 48) {
$return->limbs = array(
$this->limbs[3],
0,
0,
0,
);
}
elseif ($c >= 32) {
$return->limbs = array(
$this->limbs[2],
$this->limbs[3],
0,
0,
);
}
else {
$return->limbs = array(
$this->limbs[1],
$this->limbs[2],
$this->limbs[3],
0,
);
}
return $return
->shiftLeft($c & 15);
}
if ($c === 0) {
$return->limbs = $this->limbs;
}
elseif ($c < 0) {
/** @var int $c */
return $this
->shiftRight(-$c);
}
else {
if (!is_int($c)) {
throw new TypeError();
}
/** @var int $carry */
$carry = 0;
for ($i = 3; $i >= 0; --$i) {
/** @var int $tmp */
$tmp = $this->limbs[$i] << $c | $carry & 0xffff;
$return->limbs[$i] = (int) ($tmp & 0xffff);
/** @var int $carry */
$carry = $tmp >> 16;
}
}
return $return;
}