Does -0.5 fit an unsigned when truncated to an integer?
bodrato at mail.dm.unipi.it
bodrato at mail.dm.unipi.it
Mon Mar 18 08:28:55 CET 2013
Ciao,
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
behavior:
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...
--
http://bodrato.it/papers/
More information about the gmp-devel
mailing list