ARM Shanghai IoT Team (Internal) / newMiniTLS-GPL

Fork of MiniTLS-GPL by Donatien Garnier

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers fp_rshd.c Source File

fp_rshd.c

00001 /* TomsFastMath, a fast ISO C bignum library.
00002  * 
00003  * This project is meant to fill in where LibTomMath
00004  * falls short.  That is speed ;-)
00005  *
00006  * This project is public domain and free for all purposes.
00007  * 
00008  * Tom St Denis, tomstdenis@gmail.com
00009  */
00010 #include <tfm.h>
00011 
00012 void fp_rshd(fp_int *a, int x)
00013 {
00014   int y;
00015 
00016   /* too many digits just zero and return */
00017   if (x >= a->used) {
00018      fp_zero(a);
00019      return;
00020   }
00021 
00022    /* shift */
00023    for (y = 0; y < a->used - x; y++) {
00024       a->dp[y] = a->dp[y+x];
00025    }
00026 
00027    /* zero rest */
00028    for (; y < a->used; y++) {
00029       a->dp[y] = 0;
00030    }
00031    
00032    /* decrement count */
00033    a->used -= x;
00034    fp_clamp(a);
00035 }
00036 
00037 
00038 /* $Source: /cvs/libtom/tomsfastmath/src/bit/fp_rshd.c,v $ */
00039 /* $Revision: 1.1 $ */
00040 /* $Date: 2006/12/31 21:25:53 $ */