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_count_bits.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_count_bits (fp_int * a) 00013 { 00014 int r; 00015 fp_digit q; 00016 00017 /* shortcut */ 00018 if (a->used == 0) { 00019 return 0; 00020 } 00021 00022 /* get number of digits and add that */ 00023 r = (a->used - 1) * DIGIT_BIT; 00024 00025 /* take the last digit and count the bits in it */ 00026 q = a->dp[a->used - 1]; 00027 while (q > ((fp_digit) 0)) { 00028 ++r; 00029 q >>= ((fp_digit) 1); 00030 } 00031 return r; 00032 } 00033 00034 /* $Source: /cvs/libtom/tomsfastmath/src/bit/fp_count_bits.c,v $ */ 00035 /* $Revision: 1.1 $ */ 00036 /* $Date: 2006/12/31 21:25:53 $ */
Generated on Tue Jul 12 2022 19:20:10 by
1.7.2
