Marco Bodrato <bodr...@mail.dm.unipi.it> writes: > +int > +mpz_fits_sint_p (const mpz_t u) > +{ > + return (INT_MAX + INT_MIN == 0 || mpz_cmp_ui (u, INT_MAX) <= 0) && > + mpz_cmpabs_ui (u, GMP_NEG_CAST (unsigned long int, INT_MIN)) <= 0; > +}
I think this and mpz_fits_sshort_p would be simpler using mpz_cmp_si, int mpz_fits_sint_p (const mpz_t u) { return mpz_cmp_si (u, INT_MAX) <= 0 && mpz_cmp_si (i, INT_MIN) >= 0; } BTW, do we have any C implementation where INT_MAX + INT_MIN == 0, i.e., not using two's complement? Regards, /Niels -- Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677. Internet email is subject to wholesale government surveillance. _______________________________________________ gmp-devel mailing list gmp-devel@gmplib.org https://gmplib.org/mailman/listinfo/gmp-devel