YoushouldhavereceivedacopyoftheGNUGeneralPublicLicensealongwith
the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */
#include <stdio.h> #include <stdlib.h>
#include"gmp-impl.h" #include"tests.h"
/* Check mpz_gcd_ui doesn't try to return a value out of range.
This was wrong in gmp 4.1.2 with a long long limb. */ staticvoid
check_ui_range (void)
{ unsignedlong got;
mpz_t x; int i;
mpz_init_set_ui (x, ULONG_MAX);
for (i = 0; i < 20; i++)
{
mpz_mul_2exp (x, x, 1L);
got = mpz_gcd_ui (NULL, x, 0L); if (got != 0)
{
printf ("mpz_gcd_ui (ULONG_MAX*2^%d, 0)\n", i);
printf (" return %#lx\n", got);
printf (" should be 0\n");
abort ();
}
}
for (i = 0; i < NUM_FACTORS; ++i)
{
mpz_set_str (f, factors[i], 10); if (mpz_divisible_p (x, f))
{
mpz_mul_2exp (f, f, 1); /* d is an odd multiple of the factor f, exactly filling a limb. */
mpz_sub (d, x, f); /* f = 2^GMP_NUMB_BITS mod d. */
mpz_sub_ui (f, f, 1); break;
}
}
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.