Re: PHP number auto-converting doesn't work for negative #'s without a leading digit
| From: | Jesus M. Castagnetto | Date: | Wed, 09 Feb 2005 15:47:01 +0000 |
| Subject: | Re: PHP number auto-converting doesn't work for negative #'s without a leading digit | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-36093@lists.php.net to get a copy of this message | ||
Autoconversions in any language are not always perfect (in particular from
string representations to numbers), that is why I tend to cast in my own code.
In this case, it might be a question of tunning the Zend parser to recognize
the abbreviated construct you show as a valid float, although strictly it
should have the zero in front (it is just customary to sometimes omit it).
Also, you might want to reclassify it as a Zend Engine or Scripting Engine bug,
as the decision as to whether something looks like a float is done in places
like: php-src/ZendEngine2/zend_operators.h:is_numeric_string()
Cheers.
--- Justin Patrin <papercrane@gmail.com> wrote:
> Just thought you all might like to know:
> http://bugs.php.net/bug.php?id=31889
>
> This is a pretty simple bug which affects scripts which assume PHP
> will convert a string to a number automatically. It will except for
> strings such as: "-.55" with no leading digit. Using (float) before
> the string works fine, but the auto-conversion doesn't. See the second
> reproduce code in the bug for an example (forget the first one, I
> screwed that one up :-/ ).
>
> --
> Justin Patrin
>
> --
> PEAR Development Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
=====
--
Jesus M. Castagnetto (jcastagnetto@yahoo.com)
Web site: http://www.castagnetto.org/
Research: http://metallo.scripps.edu/
PEAR stuff: http://pear.php.net/user/jmcastagnetto
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com