#42780 [Opn->Asn]: Invalid type casting ?
| From: | tony2001@php.net | Date: | Tue, 02 Oct 2007 09:33:02 +0000 |
| Subject: | #42780 [Opn->Asn]: Invalid type casting ? | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-118054@lists.php.net to get a copy of this message | ||
ID: 42780
Updated by: tony2001@php.net
Reported By: lordi at msdi dot ca
-Status: Open
+Status: Assigned
Bug Type: SimpleXML related
Operating System: Freebsd + windows
PHP Version: 5.2.4
-Assigned To:
+Assigned To: rrichards
Previous Comments:
------------------------------------------------------------------------
[2007-09-27 16:51:25] lordi at msdi dot ca
Description:
------------
Calculations on values got from a simplexml object dont work as
expected.
String values looking as float seems to be casted as integers
Reproduce code:
---------------
<?php
$objXML = new SimpleXMLElement('<test x="-123.45"></test>');
//Shows correctly
echo $objXML['x']."\n";
//We loose the decimals
echo $objXML['x'] + $objXML['x']."\n";
//This works if we cast the amounts
echo (float)$objXML['x'] + (float)$objXML['x']."\n";
//Calculated on a string, no problem
echo "-123.45" + "-123.45";
?>
Expected result:
----------------
-123.45
-246.9
-246.9
-246.9
Actual result:
--------------
-123.45
-246
-246.9
-246.9
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42780&edit=1