Shifting any number by zero places is a no-op, but so is shifting zero by

any number of places.
This commit is contained in:
Dag-Erling Smørgrav 2014-12-29 23:20:26 +00:00 committed by des
parent 8228f19d5a
commit 1412dac680

View file

@ -42,8 +42,8 @@ mpi_lshift(cryb_mpi *X, unsigned int c)
{
unsigned int cl, i;
/* zero shift */
if (c == 0)
/* operands are zero */
if (c == 0 || X->msb == 0)
return (0);
/* make room */
if (mpi_grow(X, X->msb + c) != 0)
@ -79,8 +79,8 @@ mpi_rshift(cryb_mpi *X, unsigned int c)
{
unsigned int cl, i;
/* zero shift */
if (c == 0)
/* operands are zero */
if (c == 0 || X->msb == 0)
return (0);
/* shift wider than number, result is zero */
if (X->msb <= c) {