Re: String -> Number Automatic Conversion

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

 



Nuzzo Art-CINT116 wrote:
>               1 => "-.15" + 0,
>               6 => "-1.15" + 0,
>     [1] => 0
>     [6] => -1.15

> Is this a bug or am I missing something.

Looks like a bug to me...

It's remotely possible that it's documented somewhere that "-.15" doesn't
turn into a number, but that would be pretty bogus, eh?

But who knows:  There may well be a technical or philosophical reason for
not allowing that format.  I can't see why, but I ain't the guy writing
the code :-)

Check and file it at http://bugs.php.net

I suppose it's also remotely possible that "rounding errors" are at fault,
but that's pretty damn big round error...  More likely, the regex to
detect a "number" at the start of a string doesn't include "-.[0-9]*" as a
valid case.

Possible work-around:
I suspect that
$p1[14] = "-0.15" + 0;
will do what you want, since the leading 0 will probably trigger the regex
properly.

Try it and see.

PS You should probably have posted the PHP version and whatnot as well, as
I wouldn't be surprised if the bug is version-specific...

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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