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()
38 * Return the number of bits in A.
40 unsigned mpi_get_nbits(MPI a) in mpi_get_nbits() argument
44 mpi_normalize(a); in mpi_get_nbits()
46 if (a->nlimbs) { in mpi_get_nbits()
47 mpi_limb_t alimb = a->d[a->nlimbs - 1]; in mpi_get_nbits()
52 n = BITS_PER_MPI_LIMB - n + (a->nlimbs - 1) * BITS_PER_MPI_LIMB; in mpi_get_nbits()
62 int mpi_test_bit(MPI a, unsigned int n) in mpi_test_bit() argument
70 if (limbno >= a->nlimbs) in mpi_test_bit()
71 return 0; /* too far left: this is a 0 */ in mpi_test_bit()
72 limb = a->d[limbno]; in mpi_test_bit()
78 * Set bit N of A.
80 void mpi_set_bit(MPI a, unsigned int n) in mpi_set_bit() argument
87 if (limbno >= a->nlimbs) { in mpi_set_bit()
88 for (i = a->nlimbs; i < a->alloced; i++) in mpi_set_bit()
89 a->d[i] = 0; in mpi_set_bit()
90 mpi_resize(a, limbno+1); in mpi_set_bit()
91 a->nlimbs = limbno+1; in mpi_set_bit()
93 a->d[limbno] |= (A_LIMB_1<<bitno); in mpi_set_bit()
97 * Set bit N of A. and clear all bits above
99 void mpi_set_highbit(MPI a, unsigned int n) in mpi_set_highbit() argument
106 if (limbno >= a->nlimbs) { in mpi_set_highbit()
107 for (i = a->nlimbs; i < a->alloced; i++) in mpi_set_highbit()
108 a->d[i] = 0; in mpi_set_highbit()
109 mpi_resize(a, limbno+1); in mpi_set_highbit()
110 a->nlimbs = limbno+1; in mpi_set_highbit()
112 a->d[limbno] |= (A_LIMB_1<<bitno); in mpi_set_highbit()
114 a->d[limbno] &= ~(A_LIMB_1 << bitno); in mpi_set_highbit()
115 a->nlimbs = limbno+1; in mpi_set_highbit()
120 * clear bit N of A and all bits above
122 void mpi_clear_highbit(MPI a, unsigned int n) in mpi_clear_highbit() argument
129 if (limbno >= a->nlimbs) in mpi_clear_highbit()
133 a->d[limbno] &= ~(A_LIMB_1 << bitno); in mpi_clear_highbit()
134 a->nlimbs = limbno+1; in mpi_clear_highbit()
138 * Clear bit N of A.
140 void mpi_clear_bit(MPI a, unsigned int n) in mpi_clear_bit() argument
147 if (limbno >= a->nlimbs) in mpi_clear_bit()
149 a->d[limbno] &= ~(A_LIMB_1 << bitno); in mpi_clear_bit()
155 * Shift A by COUNT limbs to the right
158 void mpi_rshift_limbs(MPI a, unsigned int count) in mpi_rshift_limbs() argument
160 mpi_ptr_t ap = a->d; in mpi_rshift_limbs()
161 mpi_size_t n = a->nlimbs; in mpi_rshift_limbs()
165 a->nlimbs = 0; in mpi_rshift_limbs()
172 a->nlimbs -= count; in mpi_rshift_limbs()
176 * Shift A by N bits to the right.
178 void mpi_rshift(MPI x, MPI a, unsigned int n) in mpi_rshift() argument
185 if (x == a) { in mpi_rshift()
201 /* Copy and shift by more or equal bits than in a limb. */ in mpi_rshift()
202 xsize = a->nlimbs; in mpi_rshift()
203 x->sign = a->sign; in mpi_rshift()
206 for (i = 0; i < a->nlimbs; i++) in mpi_rshift()
207 x->d[i] = a->d[i]; in mpi_rshift()
225 /* Copy and shift by less than bits in a limb. */ in mpi_rshift()
226 xsize = a->nlimbs; in mpi_rshift()
227 x->sign = a->sign; in mpi_rshift()
233 mpihelp_rshift(x->d, a->d, x->nlimbs, nbits); in mpi_rshift()
236 * NBITS==0, thus we do a plain copy here. in mpi_rshift()
239 x->d[i] = a->d[i]; in mpi_rshift()
247 * Shift A by COUNT limbs to the left
250 void mpi_lshift_limbs(MPI a, unsigned int count) in mpi_lshift_limbs() argument
253 int n = a->nlimbs; in mpi_lshift_limbs()
259 RESIZE_IF_NEEDED(a, n+count); in mpi_lshift_limbs()
261 ap = a->d; in mpi_lshift_limbs()
266 a->nlimbs += count; in mpi_lshift_limbs()
270 * Shift A by N bits to the left.
272 void mpi_lshift(MPI x, MPI a, unsigned int n) in mpi_lshift() argument
277 if (x == a && !n) in mpi_lshift()
280 if (x != a) { in mpi_lshift()
281 /* Copy A to X. */ in mpi_lshift()
282 unsigned int alimbs = a->nlimbs; in mpi_lshift()
283 int asign = a->sign; in mpi_lshift()
288 ap = a->d; in mpi_lshift()
291 x->flags = a->flags; in mpi_lshift()
296 /* Shift a full number of limbs. */ in mpi_lshift()
299 /* We use a very dump approach: Shift left by the number of in mpi_lshift()