Re: Re: Supporting Binary Notation for Integers
| From: | Christian Schneider | Date: | Fri, 12 Nov 2010 10:49:33 +0000 |
| Subject: | Re: Re: Supporting Binary Notation for Integers | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-50168@lists.php.net to get a copy of this message | ||
Am 12.11.2010 um 09:22 schrieb Stan Vass:
> With regards to parsing numeric strings, only decimal is supported, and in some cases
> (unfortunately) hexadecimal, like your comparing example. But octal is not supported in strings, and
> neither should binary.
>
> 0xF == 15 // true
> '0xF' == 15 // true
> 010 == 8 // true
> '010' == 8 // false
You're right. (Side-note: '010' == 10 // true, i.e. is is parsed as a decimal number)
> It should be a important consideration that numeric string parsing isn't affected by this
> patch, and things will be fine.
If neither '0b1' == 1 nor is_numeric('0b1') is true after this patch then I see
no problem.
Sorry for not trying the patch first and assuming that it would be similar to the other formats.
> In fact it should be a separate discussion whether hex should work in strings at all. It's
> very counterproductive when parsing user input.
While you might be right this cannot be changed now as it would break compatibility without big
benefit.
- Chris