tags:

views:

66

answers:

1

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.

+3  A: 

You should check the return value of mpf_set_str. It returns 0 on success and -1 on failure. In this case it would have returned a failure and n1 is left untouched. mpf_init initialized it to zero, so testing whether zero is an integer with mpf_integer_p returns true.

laalto