FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » bug in is_numeric
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: bug in is_numeric [message #181458 is a reply to message #181454] Fri, 17 May 2013 16:33 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
SwissCheese wrote:

> On 05/16/2013 06:45 PM, Thomas 'PointedEars' Lahn wrote:
>> SwissCheese wrote:
>>> On 05/15/2013 02:49 PM, Thomas 'PointedEars' Lahn wrote:
>>>> Christoph Becker wrote:
>>>> > Thomas 'PointedEars' Lahn wrote:
>>>> >> to the above it should have returned TRUE).
>>>> >
>>>> > I can confirm issues with is_numeric() wrt. strings in binary notation
>>>> > in PHP 5.4.7:
>>>> >
>>>> > >>> is_numeric('0b1010')
>>>> > false
>>>> > >>> is_numeric(0b1010)
>>>> > true
>>>>
>>>> ACK. However, it is unsurprising to me that the latter would return
>>>> TRUE because there the literal is parsed into an “int” value *before*
>>>> it is passed to is_numeric(), the equivalent of is_numeric(10).
>>>>
>>>> I would rather the former bug was an implementation bug instead of a
>>>> documentation bug, because such a function should either work for all
>>>> supported numeric representations of the programming language, or there
>>>> should be a parameter specifying which representations are supported
>>>> for the specific call [like ECMAScripts parseInt(number : String, base
>>>> : Number) : Number].
>>>
>>> Thomas,
>>
>> This is NetNews, not e-mail.
>
> Um, ok. So you chastise people about using real names yet don't want
> yours used?

No, I am reminding you of the fact that I am not the only recipient of your
posting, even though your posting is a follow-up to mine.

>>> Looking into the source (PHP) there is no code to support binary
>>> strings of the type '0b1010101'. The code for hexadecimal is there
>>> however.
>>
>> AISB, testing with PHP does not help to resolve the basic issue here.
>> From such tests it is still unclear whether not supporting the binary
>> format is an implementation bug, i. e. an omission of supporting the
>> binary format introduced with PHP 5.4; or a documentation bug, i. e.
>> manual claiming that is_numeric() supports more than it is actually
>> supposed to.
>>
>> What would be interesting instead is to look at the source code from
>> which PHP 5.4 and particularly is_numeric() is built as that could at
>> least show if the octal format would be recognized, and if there was
>> support for the binary format that was just not properly triggered.
>
> Isn't that what I just mentioned I did ('Looking into the source
> code...') above?

I am not sure. Which source code have you been looking into?

> There is no support for binary numbers passed as strings in the form
> '0b101010'.

You are still missing the point. It is already clear to at least two people
here that there is no support. It is not clear why, as this format for
numeric literals was introduced only recently, and as the documentation
states something else.

> If you pass 0b101010 (not as a string) and it gets converted to an (int)
> on the way in then that's obviously not the same thing.

I am/We are aware of that.

> And what is so special about octal that is_numeric() would not recognise
> it?

It has no “8” figure.

> Who is this 'PointedEars', get a real name will you?

I sign my postings with the nickname under which I am known on the Net.
My first and last name are in the From header field value of my postings,
surrounding my nickname. Yours are not. Thus, you are not posting using
your real name, which is not considered polite on Usenet.


PointedEars
--
> If you get a bunch of authors […] that state the same "best practices"
> in any programming language, then you can bet who is wrong or right...
Not with javascript. Nonsense propagates like wildfire in this field.
-- Richard Cornford, comp.lang.javascript, 2011-11-14
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: problem encrypting data (AES_ENCRYPT/AES_DECRYPT)
Next Topic: Debian: php fast-cgi along with mod_php
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 06:51:17 GMT 2024

Total time taken to generate the page: 0.07271 seconds