Bug->Req #73374 [Opn]: intval() with base 0 does not detect binary
| From: | ajf@php.net | Date: | Sat, 22 Oct 2016 23:00:29 +0000 |
| Subject: | Bug->Req #73374 [Opn]: intval() with base 0 does not detect binary | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-204970@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73374&edit=1
ID: 73374
Updated by: ajf@php.net
Reported by: nikic@php.net
Summary: intval() with base 0 does not detect binary
Status: Open
-Type: Bug
+Type: Feature/Change Request
Package: Math related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
I'm recategorising this as a feature request, because intval() isn't inherently tied to
PHP's integer literal formats, much as one might wish it were.
Previous Comments:
------------------------------------------------------------------------
[2016-10-22 21:58:06] nikic@php.net
Description:
------------
intval() using base 0 currently detects decimal, octal and hexadecimal numbers based on notation.
However, binary numbers are always converted to 0. As PHP supports binary number literals as of PHP
5.4 they should be supported here as well.
https://3v4l.org/GYVQa
Test script:
---------------
var_dump(intval('0b1101', 0));
Expected result:
----------------
int(13)
Actual result:
--------------
int(0)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73374&edit=1