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

fp_cmp.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(fp_int *a, fp_int *b)
00013 {
00014    if (a->sign == FP_NEG && b->sign == FP_ZPOS) {
00015       return FP_LT;
00016    } else if (a->sign == FP_ZPOS && b->sign == FP_NEG) {
00017       return FP_GT;
00018    } else {
00019       /* compare digits */
00020       if (a->sign == FP_NEG) {
00021          /* if negative compare opposite direction */
00022          return fp_cmp_mag(b, a);
00023       } else {
00024          return fp_cmp_mag(a, b);
00025       }
00026    }
00027 }
00028 
00029 /* $Source: /cvs/libtom/tomsfastmath/src/addsub/fp_cmp.c,v $ */
00030 /* $Revision: 1.1 $ */
00031 /* $Date: 2006/12/31 21:25:53 $ */