ZF-7712: Zend_XmlRpc_Value_Double rounds to 6 decimal digits
Description
When I make a request with a double parameter like 3.39412716 , the value is sent as 3.394127 .
The rounding takes place in Zend/XmlRpc/Value/Double.php on line 48 : {{$this->_value = sprintf('%f',(float)$value); // Make sure this value is float (double) and without the scientific notation}}
Comments
Posted by Lars Strojny (lars) on 2009-08-28T07:09:53.000+0000
This is a bug due to a known behavior of sprintf(). See http://us2.php.net/manual/en/… for details. The solution would be to specify a specific precision for sprintf().
Posted by Lode Blomme (lode) on 2009-08-28T07:33:15.000+0000
Wouldn't it be possible to detect the precision of the input, and adding this to the sprintf command? Simply increasing the precision would result in added zeros at the end. That's not desirable.
Posted by Lars Strojny (lars) on 2009-08-31T06:36:34.000+0000
Fixed in r17921. Thank you for taking time to write us!
Posted by Lode Blomme (lode) on 2009-09-08T07:49:12.000+0000
This solution has the downside of adding trailing zeros to the double value in XML. If you have a message with alot of double values, this can add up to quite some extra data to be tranfered. Therefore I propose an addition to eliminate those trailing zeros :
Posted by Lars Strojny (lars) on 2009-12-09T19:39:40.000+0000
Fixed in trunk (r19562) and 1.9 release branch (r19563). We now trim trailing "0"s when building the XML envelope
Posted by Adam Kusmierz (raistlin) on 2010-02-17T10:54:34.000+0000
You can't use printf's schema "f", bacause it's locale aware. On Windows, this function returns float, but rounded to decimal part (ie. 1 instead 1.123).
You should use "F" instead:
Posted by Matthew Weier O'Phinney (matthew) on 2010-02-23T09:57:12.000+0000
Fixed in trunk and 1.10 release branch.