From ca01897d64baad43459268cfdb516baa6e7dfc95 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Mon, 10 Sep 2012 01:54:11 +0000 Subject: [PATCH] Fix doc bug #63027 (dechex may convert numbers up to PHP_INT_MAX) by clarifying that PHP treats the parameter as an unsigned int, and working through some of the implications of that from a userland perspective. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@327571 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/math/functions/dechex.xml | 45 +++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/reference/math/functions/dechex.xml b/reference/math/functions/dechex.xml index a6dff019fd..6099c4e72c 100644 --- a/reference/math/functions/dechex.xml +++ b/reference/math/functions/dechex.xml @@ -12,9 +12,15 @@ intnumber - Returns a string containing a hexadecimal representation of the - given number argument. The largest number that can - be converted is 4294967295 in decimal resulting to "ffffffff". + Returns a string containing a hexadecimal representation of the given + unsigned number argument. + + + The largest number that can be converted is + PHP_INT_MAX * 2 + 1 (or + -1): on 32-bit platforms, this will be + 4294967295 in decimal, which results in + dechex returning ffffffff. @@ -25,7 +31,12 @@ number - Decimal value to convert + The decimal value to convert. + + + As PHP's integer type is signed, but + dechex deals with unsigned integers, negative + integers will be treated as though they were unsigned. @@ -35,7 +46,7 @@ &reftitle.returnvalues; - Hexadecimal string representation of number + Hexadecimal string representation of number. @@ -56,6 +67,30 @@ echo dechex(47); + + + + + + <function>dechex</function> example with large integers + + +]]> + + &example.outputs; + +