YoushouldhavereceivedcopiesoftheGNUGeneralPublicLicenseandthe GNULesserGeneralPublicLicensealongwiththeGNUMPLibrary.Ifnot,
see https://www.gnu.org/licenses/. */
#include"gmp-impl.h" #include"longlong.h"
int
mpf_eq (mpf_srcptr u, mpf_srcptr v, mp_bitcnt_t n_bits)
{
mp_srcptr up, vp, p;
mp_size_t usize, vsize, minsize, maxsize, n_limbs, i, size;
mp_exp_t uexp, vexp;
mp_limb_t diff; int cnt;
uexp = u->_mp_exp;
vexp = v->_mp_exp;
usize = u->_mp_size;
vsize = v->_mp_size;
/* 1. Are the signs different? */ if ((usize ^ vsize) >= 0)
{ /* U and V are both non-negative or both negative. */ if (usize == 0) return vsize == 0; if (vsize == 0) return0;
/* Fall out. */
} else
{ /* Either U or V is negative, but not both. */ return0;
}
/* U and V have the same sign and are both non-zero. */
/* 2. Are the exponents different? */ if (uexp != vexp) return0;
usize = ABS (usize);
vsize = ABS (vsize);
up = u->_mp_d;
vp = v->_mp_d;
up += usize; /* point just above most significant limb */
vp += vsize; /* point just above most significant limb */
count_leading_zeros (cnt, up[-1]); if ((vp[-1] >> (GMP_LIMB_BITS - 1 - cnt)) != 1) return0; /* msb positions different */
up -= minsize; /* point at most significant common limb */
vp -= minsize; /* point at most significant common limb */
/* Compare the most significant part which has explicit limbs for U and V. */ for (i = minsize - 1; i > 0; i--)
{ if (up[i] != vp[i]) return0;
}
n_bits -= (maxsize - 1) * GMP_NUMB_BITS;
size = maxsize - minsize; if (size != 0)
{ if (up[0] != vp[0]) return0;
/* Now either U or V has its limbs consumed, i.e, continues with an infinitenumberofimplicitzerolimbs.Checkthattheotheroperand
has just zeros in the corresponding, relevant part. */
if (usize > vsize)
p = up - size; else
p = vp - size;
for (i = size - 1; i > 0; i--)
{ if (p[i] != 0) return0;
}
diff = p[0];
} else
{ /* Both U or V has its limbs consumed. */
diff = up[0] ^ vp[0];
}
if (n_bits < GMP_NUMB_BITS)
diff >>= GMP_NUMB_BITS - n_bits;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.