]> pd.if.org Git - zpackage/blob - tomsfastmath/src/exptmod/fp_2expt.c
commit files needed for zpm-fetchurl
[zpackage] / tomsfastmath / src / exptmod / fp_2expt.c
1 /* TomsFastMath, a fast ISO C bignum library.
2  * 
3  * This project is meant to fill in where LibTomMath
4  * falls short.  That is speed ;-)
5  *
6  * This project is public domain and free for all purposes.
7  * 
8  * Tom St Denis, tomstdenis@gmail.com
9  */
10 #include <tfm_private.h>
11
12 /* computes a = 2**b */
13 void fp_2expt(fp_int *a, int b)
14 {
15    int     z;
16
17    /* zero a as per default */
18    fp_zero (a);
19
20    if (b < 0) { 
21       return;
22    }
23
24    z = b / DIGIT_BIT;
25    if (z >= FP_SIZE) {
26       return; 
27    }
28
29   /* set the used count of where the bit will go */
30   a->used = z + 1;
31
32   /* put the single bit in its place */
33   a->dp[z] = ((fp_digit)1) << (b % DIGIT_BIT);
34 }
35
36
37 /* $Source$ */
38 /* $Revision$ */
39 /* $Date$ */