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

fp_lcm.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 /* c = [a, b] */
00013 void fp_lcm(fp_int *a, fp_int *b, fp_int *c)
00014 {
00015    fp_int  t1, t2;
00016 
00017    fp_init(&t1);
00018    fp_init(&t2);
00019    fp_gcd(a, b, &t1);
00020    if (fp_cmp_mag(a, b) == FP_GT) {
00021       fp_div(a, &t1, &t2, NULL);
00022       fp_mul(b, &t2, c);
00023    } else {
00024       fp_div(b, &t1, &t2, NULL);
00025       fp_mul(a, &t2, c);
00026    }   
00027 }
00028 
00029 /* $Source: /cvs/libtom/tomsfastmath/src/numtheory/fp_lcm.c,v $ */
00030 /* $Revision: 1.1 $ */
00031 /* $Date: 2007/01/24 21:25:19 $ */