diff options
author | Werner Koch <[email protected]> | 1997-11-27 11:44:13 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 1997-11-27 11:44:13 +0000 |
commit | 649eae8f1b689e90695bbf24b636ca941dfb9689 (patch) | |
tree | 60b137945a1dc6a64dd5846864229c33dc86cf49 /mpi/mpi-scan.c | |
parent | How with some assembly support (diff) | |
download | gnupg-649eae8f1b689e90695bbf24b636ca941dfb9689.tar.gz gnupg-649eae8f1b689e90695bbf24b636ca941dfb9689.zip |
Improved prime number test
Diffstat (limited to 'mpi/mpi-scan.c')
-rw-r--r-- | mpi/mpi-scan.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mpi/mpi-scan.c b/mpi/mpi-scan.c index 8626032a0..b9745e1af 100644 --- a/mpi/mpi-scan.c +++ b/mpi/mpi-scan.c @@ -22,6 +22,7 @@ #include <stdio.h> #include <stdlib.h> #include "mpi-internal.h" +#include "longlong.h" /**************** * Scan through an mpi and return byte for byte. a -1 is returned to indicate @@ -86,3 +87,28 @@ mpi_putbyte( MPI a, unsigned index, int c ) abort(); /* index out of range */ } + +/**************** + * Count the number of zerobits at the low end of A + */ +unsigned +mpi_trailing_zeros( MPI a ) +{ + unsigned n, count = 0; + + for(n=0; n < a->nlimbs; n++ ) { + if( a->d[n] ) { + unsigned nn; + mpi_limb_t alimb = a->d[n]; + + count_trailing_zeros( nn, alimb ); + count += nn; + break; + } + count += BITS_PER_MPI_LIMB; + } + return count; + +} + + |