mpf_fits_u*_p treatment of negative values greater than -1.0

sisyphus1 at optusnet.com.au sisyphus1 at optusnet.com.au
Fri Nov 22 11:17:33 UTC 2013


Hi,

mpf_fits_ulong_p(), mpf_fits_uint_p() and mpf_fits_ushort_p() all return 
false for negative values greater than -1.

I believe they should return true for such values - as happens if I first 
call mpf_trunc().
Here's the demo script:

/************************************/
#include <stdio.h>
#include <gmp.h>

int main(void) {

mpf_t a;

printf("Version: %s\n", gmp_version);

mpf_init_set_d(a, -0.5);

printf("fits: %d %d %d\n",
         mpf_fits_uint_p(a),
         mpf_fits_ulong_p(a),
         mpf_fits_ushort_p(a));

mpf_trunc(a, a);

printf("fits: %d %d %d\n",
         mpf_fits_uint_p(a),
         mpf_fits_ulong_p(a),
         mpf_fits_ushort_p(a));

return 0;
}

/************************************/

For me, that ouptuts:

Version: 5.1.3
fits: 0 0 0
fits: 1 1 1

Has this been raised here before ?
I saw it raised somewhere quite a while ago ... but perhaps no-one ever 
filed a bug report about it ... or perhaps there's some other explanation 
that nothing has been done to change the behaviour.

Cheers,
Rob 



More information about the gmp-bugs mailing list