bn_mp_clamp.cGo to the documentation of this file.00001 #include <tommath.h> 00002 #ifdef BN_MP_CLAMP_C 00003 /* LibTomMath, multiple-precision integer library -- Tom St Denis 00004 * 00005 * LibTomMath is a library that provides multiple-precision 00006 * integer arithmetic as well as number theoretic functionality. 00007 * 00008 * The library was designed directly after the MPI library by 00009 * Michael Fromberger but has been written from scratch with 00010 * additional optimizations in place. 00011 * 00012 * The library is free for all purposes without any express 00013 * guarantee it works. 00014 * 00015 * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com 00016 */ 00017 00018 /* trim unused digits 00019 * 00020 * This is used to ensure that leading zero digits are 00021 * trimed and the leading "used" digit will be non-zero 00022 * Typically very fast. Also fixes the sign if there 00023 * are no more leading digits 00024 */ 00025 void 00026 mp_clamp (mp_int * a) 00027 { 00028 /* decrease used while the most significant digit is 00029 * zero. 00030 */ 00031 while (a->used > 0 && a->dp[a->used - 1] == 0) { 00032 --(a->used); 00033 } 00034 00035 /* reset the sign flag if used == 0 */ 00036 if (a->used == 0) { 00037 a->sign = MP_ZPOS; 00038 } 00039 } 00040 #endif 00041 00042 /* $Source: /cvsroot/tcl/libtommath/bn_mp_clamp.c,v $ */ 00043 /* $Revision: 1.1.1.3 $ */ 00044 /* $Date: 2006/12/01 00:08:11 $ */
Generated on Wed Mar 12 12:18:24 2008 by 1.5.1 |