To this bit of code I pass the string "kellogs special k" and I get 1 which means that the string is an integer. What on earth am I doing wrong? Or is it a GMP problem?
#define F(x) mpf_t (x); mpf_init( (x) );
long __stdcall FBIGISINTEGER(BSTR p1) {
USES_CONVERSION;
F(n1);
LPSTR sNum1 = W2A( p1 );
mpf_set_str( n1, sNum1, 10 );
return mpf_integer_p( n1 );
}
By the way, if anyone’s going to suggest using a more recent GMP, please can you give me the web address of the static LIB for Windows. TIA.
You should check the return value of
mpf_set_str. It returns0on success and-1on failure. In this case it would have returned a failure andn1is left untouched.mpf_initinitialized it to zero, so testing whether zero is an integer withmpf_integer_preturns true.