String -> Number Automatic Conversion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux