mirror of
https://github.com/cryb-to/cryb-to.git
synced 2025-01-03 02:11:10 +00:00
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:
parent
8228f19d5a
commit
1412dac680
1 changed files with 4 additions and 4 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue