diff options
author | tege <tege@gmplib.org> | 1999-02-22 22:27:59 +0100 |
---|---|---|
committer | tege <tege@gmplib.org> | 1999-02-22 22:27:59 +0100 |
commit | 3aa0d7d19496d3c2faf65b189b4458462e45e263 (patch) | |
tree | 77e7b5c13cc454797b1997607f594b72b46ecd30 /mpf | |
parent | df6116c980666e3344ed08701a4736bd9b65a7fd (diff) | |
download | gmp-3aa0d7d19496d3c2faf65b189b4458462e45e263.tar.gz |
* Compare most significant mantissa limb before trying to deduce anything from
the limb count.
Diffstat (limited to 'mpf')
-rw-r--r-- | mpf/cmp_si.c | 16 | ||||
-rw-r--r-- | mpf/cmp_ui.c | 14 |
2 files changed, 15 insertions, 15 deletions
diff --git a/mpf/cmp_si.c b/mpf/cmp_si.c index 01f970812..d2457a995 100644 --- a/mpf/cmp_si.c +++ b/mpf/cmp_si.c @@ -72,9 +72,15 @@ mpf_cmp_si (u, vslimb) up = u->_mp_d; + /* 3. Compare the most significant mantissa limb with V. */ + if (up[usize - 1] > vslimb) + return usign; + else if (up[usize - 1] < vslimb) + return -usign; + #define STRICT_MPF_NORMALIZATION 0 #if ! STRICT_MPF_NORMALIZATION - /* Ignore zeroes at the low end of U and V. */ + /* Ignore zeroes at the low end of U. */ while (*up == 0) { up++; @@ -82,17 +88,11 @@ mpf_cmp_si (u, vslimb) } #endif - /* 3. Now, if the number of limbs are different, we have a difference + /* 4. Now, if the number of limbs are different, we have a difference since we have made sure the trailing limbs are not zero. */ if (usize > 1) return usign; - /* 4. Compare the mantissas. */ - if (*up > vslimb) - return usign; - else if (*up < vslimb) - return -usign; - /* Wow, we got zero even if we tried hard to avoid it. */ return 0; } diff --git a/mpf/cmp_ui.c b/mpf/cmp_ui.c index 3a4911ba7..e38ceb4a5 100644 --- a/mpf/cmp_ui.c +++ b/mpf/cmp_ui.c @@ -54,6 +54,12 @@ mpf_cmp_ui (u, vlimb) up = u->_mp_d; + /* 3. Compare the most significant mantissa limb with V. */ + if (up[usize - 1] > vlimb) + return 1; + else if (up[usize - 1] < vlimb) + return -1; + #define STRICT_MPF_NORMALIZATION 0 #if ! STRICT_MPF_NORMALIZATION /* Ignore zeroes at the low end of U. */ @@ -64,17 +70,11 @@ mpf_cmp_ui (u, vlimb) } #endif - /* 3. Now, if the number of limbs are different, we have a difference + /* 4. Now, if the number of limbs are different, we have a difference since we have made sure the trailing limbs are not zero. */ if (usize > 1) return 1; - /* 4. Compare the mantissas. */ - if (*up > vlimb) - return 1; - else if (*up < vlimb) - return -1; - /* Wow, we got zero even if we tried hard to avoid it. */ return 0; } |