Does -0.5 fit an unsigned when truncated to an integer?
Paul.Zimmermann at inria.fr
Mon Mar 18 09:35:14 CET 2013
> Date: Mon, 18 Mar 2013 08:28:55 +0100 (CET)
> From: bodrato at mail.dm.unipi.it
> I was reading some sources in mpf, and I do not understand a detail.
> Documentation of mpf_fits_uint_p reads:
> "Return non-zero if op would fit in the respective C data type, when
> truncated to an integer."
> The source code contains the comment:
> /* Notice this is equivalent to mpz_set_f + mpz_fits_u*_p. */
> But mpf_fits_uint_p (-0.5) returns zero, and our test suite require this
> mpf_set_str_or_abort (f, "-0.5", 10);
> expr = "-0.5";
> EXPECT (mpf_fits_ulong_p, 0);
> EXPECT (mpf_fits_uint_p, 0);
> EXPECT (mpf_fits_ushort_p, 0);
> I don't understand...
indeed this is inconsistent. mpf_fits_uint_p(-0.5) should return true, as well
More information about the gmp-devel