comparison tomsfastmath/src/exptmod/fp_2expt.c @ 643:a362b62d38b2 dropbear-tfm

Add tomsfastmath from git rev bfa4582842bc3bab42e4be4aed5703437049502a with Makefile.in renamed
author Matt Johnston <matt@ucc.asn.au>
date Wed, 23 Nov 2011 18:10:20 +0700
parents
children
comparison
equal deleted inserted replaced
642:33fd2f3499d2 643:a362b62d38b2
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, [email protected]
9 */
10 #include <tfm.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$ */