You are here: Re: [PHP] String -> Number Automatic Conversion « PHP « IT news, forums, messages
Re: [PHP] String -> Number Automatic Conversion

Posted by Richard Lynch on 10/02/00 11:07

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация