String -> Number Automatic Conversion
| From: | Nuzzo Art-CINT116 | Date: | Thu, 03 Feb 2005 16:06:49 +0000 |
| Subject: | String -> Number Automatic Conversion | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-207997@lists.php.net to get a copy of this message | ||
I am not sure if this is a bug or I am just doing something dumb but I am having a problem with
automatic converting of strings to a number between 0 and -1. For example:
$p1 = Array ( 0 => "-.15",
1 => "-.15" + 0,
2 => (float) "-.15" + 0,
5 => "-1.15",
6 => "-1.15" + 0,
7 => (float) "-1.15" + 0,
8 => ".15",
9 => ".15" + 0,
10 => (float) ".15" + 0,
11 => "1.15",
12 => "1.5" + 0,
13 => (float) "1.5" + 0
);
If I print $p1 I get:
Array
(
[0] => -.15
[1] => 0
[2] => -0.15
[5] => -1.15
[6] => -1.15
[7] => -1.15
[8] => .15
[9] => 0.15
[10] => 0.15
[11] => 1.15
[12] => 1.5
[13] => 1.5
)
Note that the results for element [1] is 0 not -.15 as I had expected. It does not matter what
value is added to the string. Any value outside the range of -1 < value < 0 gives the
correct results.
Is this a bug or am I missing something.
Thanks for any help,
Art Nuzzo