2004-08-25 04:43:43 +02:00
|
|
|
/* TomsFastMath, a fast ISO C bignum library.
|
|
|
|
*
|
|
|
|
* This project is meant to fill in where LibTomMath
|
|
|
|
* falls short. That is speed ;-)
|
|
|
|
*
|
|
|
|
* This project is public domain and free for all purposes.
|
|
|
|
*
|
2005-07-23 12:43:03 +02:00
|
|
|
* Tom St Denis, tomstdenis@gmail.com
|
2004-08-25 04:43:43 +02:00
|
|
|
*/
|
2015-08-11 23:26:06 +02:00
|
|
|
#include <tfm_private.h>
|
2004-08-25 04:43:43 +02:00
|
|
|
|
|
|
|
/* computes a = 2**b */
|
|
|
|
void fp_2expt(fp_int *a, int b)
|
|
|
|
{
|
|
|
|
int z;
|
|
|
|
|
|
|
|
/* zero a as per default */
|
|
|
|
fp_zero (a);
|
|
|
|
|
|
|
|
if (b < 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
z = b / DIGIT_BIT;
|
|
|
|
if (z >= FP_SIZE) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the used count of where the bit will go */
|
|
|
|
a->used = z + 1;
|
|
|
|
|
|
|
|
/* put the single bit in its place */
|
|
|
|
a->dp[z] = ((fp_digit)1) << (b % DIGIT_BIT);
|
|
|
|
}
|
|
|
|
|
2005-07-23 12:43:03 +02:00
|
|
|
|
|
|
|
/* $Source$ */
|
|
|
|
/* $Revision$ */
|
|
|
|
/* $Date$ */
|