diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2011-03-14 11:59:15 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2011-03-14 11:59:15 (GMT) |
commit | b7a189417b38e35bb825490a1b9a15fc8d138333 (patch) | |
tree | 4944895fd2b42a16491f59f9c1cb12ffda552245 /libtommath/bn_mp_div_d.c | |
parent | b5c43fbc876f3a372f5d83509d70f648ae9d6b88 (diff) | |
download | tcl-b7a189417b38e35bb825490a1b9a15fc8d138333.zip tcl-b7a189417b38e35bb825490a1b9a15fc8d138333.tar.gz tcl-b7a189417b38e35bb825490a1b9a15fc8d138333.tar.bz2 |
Import of libtommath 0.41
Import of libtommath 0.41
Diffstat (limited to 'libtommath/bn_mp_div_d.c')
-rw-r--r-- | libtommath/bn_mp_div_d.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libtommath/bn_mp_div_d.c b/libtommath/bn_mp_div_d.c index d64b4b5..6a26d4f 100644 --- a/libtommath/bn_mp_div_d.c +++ b/libtommath/bn_mp_div_d.c @@ -19,7 +19,12 @@ static int s_is_power_of_two(mp_digit b, int *p) { int x; - for (x = 1; x < DIGIT_BIT; x++) { + /* fast return if no power of two */ + if ((b==0) || (b & (b-1))) { + return 0; + } + + for (x = 0; x < DIGIT_BIT; x++) { if (b == (((mp_digit)1)<<x)) { *p = x; return 1; @@ -106,5 +111,5 @@ int mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d) #endif /* $Source: /cvs/libtom/libtommath/bn_mp_div_d.c,v $ */ -/* $Revision: 1.4 $ */ -/* $Date: $ */ +/* $Revision: 1.5 $ */ +/* $Date: 2007/01/09 04:44:32 $ */ |