Menu

#9 truncation of double

open
5
2003-11-21
2003-11-21
AMP
No

When returning a double, XmlRpc++ truncates its
precision, as in the example below,

void execute(XmlRpcValue& params, XmlRpcValue& result)

{
double res = 1.7872827392;
result = res;
}

where the double 1.7872827392 should have been
returned. Instead the returned value is
1.787283

This is due to the XmlRpcValue::ToXml, which indirect
uses the _doubleFormat string, defined as follows:

std::string XmlRpcValue::_doubleFormat("%f");

So the transmitted Xml string is
<value><double>1.787283</double></value>

A solution could be the _doubleFormat("%.17f)

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.