Lines Matching full:a

13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * You should have received a copy of the GNU General Public License
30 void mpi_normalize(MPI a) in mpi_normalize() argument
32 for (; a->nlimbs && !a->d[a->nlimbs - 1]; a->nlimbs--) in mpi_normalize()
37 * Return the number of bits in A.
39 unsigned mpi_get_nbits(MPI a) in mpi_get_nbits() argument
43 mpi_normalize(a); in mpi_get_nbits()
45 if (a->nlimbs) { in mpi_get_nbits()
46 mpi_limb_t alimb = a->d[a->nlimbs - 1]; in mpi_get_nbits()
51 n = BITS_PER_MPI_LIMB - n + (a->nlimbs - 1) * BITS_PER_MPI_LIMB; in mpi_get_nbits()
61 int mpi_test_bit(MPI a, unsigned n) in mpi_test_bit() argument
69 if (limbno >= a->nlimbs) in mpi_test_bit()
70 return 0; /* too far left: this is a 0 */ in mpi_test_bit()
71 limb = a->d[limbno]; in mpi_test_bit()
76 * Set bit N of A.
78 int mpi_set_bit(MPI a, unsigned n) in mpi_set_bit() argument
85 if (limbno >= a->nlimbs) { /* resize */ in mpi_set_bit()
86 if (a->alloced >= limbno) in mpi_set_bit()
87 if (mpi_resize(a, limbno + 1) < 0) in mpi_set_bit()
89 a->nlimbs = limbno + 1; in mpi_set_bit()
91 a->d[limbno] |= (A_LIMB_1 << bitno); in mpi_set_bit()
96 * Set bit N of A. and clear all bits above
98 int mpi_set_highbit(MPI a, unsigned n) in mpi_set_highbit() argument
105 if (limbno >= a->nlimbs) { /* resize */ in mpi_set_highbit()
106 if (a->alloced >= limbno) in mpi_set_highbit()
107 if (mpi_resize(a, limbno + 1) < 0) in mpi_set_highbit()
109 a->nlimbs = limbno + 1; in mpi_set_highbit()
111 a->d[limbno] |= (A_LIMB_1 << bitno); in mpi_set_highbit()
113 a->d[limbno] &= ~(A_LIMB_1 << bitno); in mpi_set_highbit()
114 a->nlimbs = limbno + 1; in mpi_set_highbit()
119 * clear bit N of A and all bits above
121 void mpi_clear_highbit(MPI a, unsigned n) in mpi_clear_highbit() argument
128 if (limbno >= a->nlimbs) in mpi_clear_highbit()
132 a->d[limbno] &= ~(A_LIMB_1 << bitno); in mpi_clear_highbit()
133 a->nlimbs = limbno + 1; in mpi_clear_highbit()
137 * Clear bit N of A.
139 void mpi_clear_bit(MPI a, unsigned n) in mpi_clear_bit() argument
146 if (limbno >= a->nlimbs) in mpi_clear_bit()
148 a->d[limbno] &= ~(A_LIMB_1 << bitno); in mpi_clear_bit()
152 * Shift A by N bits to the right
153 * FIXME: should use alloc_limb if X and A are same.
155 int mpi_rshift(MPI x, MPI a, unsigned n) in mpi_rshift() argument
160 xsize = a->nlimbs; in mpi_rshift()
161 x->sign = a->sign; in mpi_rshift()
167 mpihelp_rshift(xp, a->d, xsize, n); in mpi_rshift()
175 * Shift A by COUNT limbs to the left
178 int mpi_lshift_limbs(MPI a, unsigned int count) in mpi_lshift_limbs() argument
180 mpi_ptr_t ap = a->d; in mpi_lshift_limbs()
181 int n = a->nlimbs; in mpi_lshift_limbs()
187 if (RESIZE_IF_NEEDED(a, n + count) < 0) in mpi_lshift_limbs()
194 a->nlimbs += count; in mpi_lshift_limbs()
199 * Shift A by COUNT limbs to the right
202 void mpi_rshift_limbs(MPI a, unsigned int count) in mpi_rshift_limbs() argument
204 mpi_ptr_t ap = a->d; in mpi_rshift_limbs()
205 mpi_size_t n = a->nlimbs; in mpi_rshift_limbs()
209 a->nlimbs = 0; in mpi_rshift_limbs()
216 a->nlimbs -= count; in mpi_rshift_limbs()