Stanislav Malyshev wrote:
While looking at bug 42780: http://bugs.php.net/bug.php?id=42780
The only way not to lose precision is to explicitly cast the object
to float or string, which just doesn't seem right to me.
I'm not sure how this can be fixed - there should be some type used
and many objects won't provide convertor to float... Anyway, it's
probably not the best idea to rely on default conversion in this
context - better to specify it.
I would have agreed 100% that explicit casting should be used, but with
to_string around, it just doesn't seem right now.Take the following:
$xml = '<root><a>1.1</a><b>2.2</b></root>';
$sxe = simplexml_load_string($xml);
print $sxe->a ." + ".$sxe->b." = ".($sxe->a +$sxe->b);
1.1 + 2.2 = 3
And why wouldn't objects provide a float converter? If they provided a
converter to long why wouldn't they also provide means to convert to float.
Rob
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php