Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MiniTLS-GPL by
fp_add.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_add(fp_int *a, fp_int *b, fp_int *c) 00013 { 00014 int sa, sb; 00015 00016 /* get sign of both inputs */ 00017 sa = a->sign; 00018 sb = b->sign; 00019 00020 /* handle two cases, not four */ 00021 if (sa == sb) { 00022 /* both positive or both negative */ 00023 /* add their magnitudes, copy the sign */ 00024 c->sign = sa; 00025 s_fp_add (a, b, c); 00026 } else { 00027 /* one positive, the other negative */ 00028 /* subtract the one with the greater magnitude from */ 00029 /* the one of the lesser magnitude. The result gets */ 00030 /* the sign of the one with the greater magnitude. */ 00031 if (fp_cmp_mag (a, b) == FP_LT) { 00032 c->sign = sb; 00033 s_fp_sub (b, a, c); 00034 } else { 00035 c->sign = sa; 00036 s_fp_sub (a, b, c); 00037 } 00038 } 00039 } 00040 00041 /* $Source: /cvs/libtom/tomsfastmath/src/addsub/fp_add.c,v $ */ 00042 /* $Revision: 1.1 $ */ 00043 /* $Date: 2006/12/31 21:25:53 $ */
Generated on Tue Jul 12 2022 19:20:10 by
1.7.2
