aboutsummaryrefslogtreecommitdiffstats
path: root/mpi/mpi-bit.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--mpi/mpi-bit.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/mpi/mpi-bit.c b/mpi/mpi-bit.c
index eff7be259..cae29d225 100644
--- a/mpi/mpi-bit.c
+++ b/mpi/mpi-bit.c
@@ -135,6 +135,25 @@ mpi_set_highbit( MPI a, unsigned n )
}
/****************
+ * clear bit N of A and all bits above
+ */
+void
+mpi_clear_highbit( MPI a, unsigned n )
+{
+ unsigned limbno, bitno;
+
+ limbno = n / BITS_PER_MPI_LIMB;
+ bitno = n % BITS_PER_MPI_LIMB;
+
+ if( limbno >= a->nlimbs )
+ return; /* not allocated, so need to clear bits :-) */
+
+ for( ; bitno < BITS_PER_MPI_LIMB; bitno++ )
+ a->d[limbno] &= ~(A_LIMB_1 << bitno);
+ a->nlimbs = limbno+1;
+}
+
+/****************
* Clear bit N of A.
*/
void