note 64984 deleted from language.types.type-juggling by betz
| From: | betz@php.net | Date: | Mon, 24 Apr 2006 09:10:32 +0000 |
| Subject: | note 64984 deleted from language.types.type-juggling by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-109303@lists.php.net to get a copy of this message | ||
Note Submitter:
----
Sorry, I am resubmitting this, as I needed to slightly fix my last submission:
There seems to be a problem with string hexadecimals and type juggling.
The following expectedly ignores the hexadecimal value since floats are only specifiable in decimal.
<?php
var_dump ((float) "0x31"); // (float)0
var_dump (1.5+(float)"0x31"); // (float)1.5
?>
However, the following seems to first convert the hexadecimal string to an integer (which does allow
hexadecimals) and then to a float, rather than immediately converting to float, as the documentation
here on type juggling would have it:
<?php
var_dump (1.5+"0x31"); // (float)50.5 (i.e., 1.5+49)
?>