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_cmp_mag.c Source File

fp_cmp_mag.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 int fp_cmp_mag(fp_int *a, fp_int *b)
00013 {
00014    int x;
00015 
00016    if (a->used > b->used) {
00017       return FP_GT;
00018    } else if (a->used < b->used) {
00019       return FP_LT;
00020    } else {
00021       for (x = a->used - 1; x >= 0; x--) {
00022           if (a->dp[x] > b->dp[x]) {
00023              return FP_GT;
00024           } else if (a->dp[x] < b->dp[x]) {
00025              return FP_LT;
00026           }
00027       }
00028    }
00029    return FP_EQ;
00030 }
00031 
00032 
00033 /* $Source: /cvs/libtom/tomsfastmath/src/addsub/fp_cmp_mag.c,v $ */
00034 /* $Revision: 1.1 $ */
00035 /* $Date: 2006/12/31 21:25:53 $ */