Bug #52950 [Opn->Csd]: Wrong implicit conversion of strings containing hexadecimal numbers to int

From: Date: Sun, 08 Feb 2015 10:23:45 +0000
Subject: Bug #52950 [Opn->Csd]: Wrong implicit conversion of strings containing hexadecimal numbers to int
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190529@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=52950&edit=1 ID: 52950 Updated by: nikic@php.net Reported by: confik at gmail dot com Summary: Wrong implicit conversion of strings containing hexadecimal numbers to int -Status: Open +Status: Closed Type: Bug Package: Scripting Engine problem Operating System: Linux 2.6.32 Ubuntu 10.04/i686 -PHP Version: 5.3.3 +PHP Version: 7.0.0 -Assigned To: +Assigned To: nikic Block user comment: N Private report: N New Comment: Fixed in PHP 7, by removing hex-string support in the cases where it existed. Previous Comments: ------------------------------------------------------------------------ [2013-05-18 12:33:20] cmbecker69 at gmx dot de IMO the behavior of the implicit type juggling is correct, and the result of the explicit type cast is erroneous in this regard. Anyway, both results should match. ------------------------------------------------------------------------ [2010-09-29 10:49:25] confik at gmail dot com Description: ------------ If string contains hexadecimal number, such as '0x05' it correctly explicitly casts to integer(resulting zero): php > var_dump((int) '0x05'); int(0) but incorrectly casts implicitly (resulting its value, 5) php > var_dump(1 * '0x05'); int(5) Same for floats: php > var_dump((float) '0xffffffffff'); float(0) php > var_dump(1 * '0xffffffffff'); float(1099511627775) P.S.: Tests were made on x86 (i686) Linux machine. Test script: --------------- <?php var_dump(1 * '0x05'); var_dump(1 * '0xffffffffff'); Expected result: ---------------- int(0) float(0) Actual result: -------------- int(5) float(1099511627775) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=52950&edit=1

« previous php.bugs (#190529) next »