<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<font face="arial" size="2">G'day everyone<br>
<br>
Context:<br>
gmp-static-vc-4.1.2<br>
Microsoft Visual C++ 6.0 <br>
Windows XP Professional SP3<br>
<br>
In the code below I use mpf_add in what I assume to be the canonical
way. What I don't understand at this point is why 2.2 + 3.2 =
5.39999999999999999999999999999999999999. I would have thought that<br>
gmp was smart enough to give 5.4.<br>
<br>
What else should I be seeing in the manual that I'm not?<br>
<br>
Kind regards,<br>
<br>
Bruce M. Axtens<br>
Software Engineer<br>
The Protium Project<br>
<br>
---<br>
<br>
#define F(x) mpf_t x; mpf_init( x );<br>
<br>
BSTR __stdcall FBIGSUM(BSTR p1, BSTR p2 ) {<br>
USES_CONVERSION;<br>
<br>
F(n1);<br>
F(n2);<br>
F(res);<br>
<br>
LPSTR sNum1 = W2A( p1 );<br>
LPSTR sNum2 = W2A( p2 );<br>
<br>
mpf_set_str( n1, sNum1, 10 );<br>
mpf_set_str( n2, sNum2, 10 );<br>
<br>
mpf_add( res, n1, n2 );<br>
<br>
char * buff = (char *) _alloca( 1024 );<br>
char expBuffer[ 20 ];<br>
mp_exp_t exp;<br>
<br>
mpf_get_str(buff, &exp, 10, 0, res);<br>
<br>
char * temp = ltoa( (long) exp, expBuffer, 10 );<br>
if (exp >= 0) {<br>
strcat(buff, "+" );<br>
}<br>
strcat(buff, expBuffer );<br>
<br>
BSTR bResult = _com_util::ConvertStringToBSTR( buff );<br>
return bResult;<br>
}<br>
<br>
</font>
<br>
<br>
</body>
</html>