ID: 35874
User updated by: chris at acsi dot ca
Reported By: chris at acsi dot ca
Status: Open
Bug Type: Documentation problem
Operating System: Windows XP Sp2
PHP Version: 5.1.1
New Comment:
Yes, I'm familiar with processor limitations, but there is no reason
why this function should be limited that way. This problem shows up
with a number of 8 bits at maximum size (18446744073709551615 dec
unsigned). You can also get the problem with a number of FFFFFFFFFFFFF
hex unsigned, which is between 4 and 8 bits.
What type of math is the function doing that an 8 bit number is being
mangled by a 32 bit OS/CPU limitation?
The documentation does not mention any limitation, so either the
documentation should be updated to reflect it's limitations (which is a
cop out), or the logic should be updated to follow something similar to
the many posts people have left under the base_convert() manual entry.
Am I missing something here? It still sounds like the function is
broken.
Previous Comments:
------------------------------------------------------------------------
[2006-01-03 08:52:47] [EMAIL PROTECTED]
Never heard about 32bits and some limits there are to it?
------------------------------------------------------------------------
[2006-01-03 02:04:01] chris at acsi dot ca
Description:
------------
base_convert($str, 10, 16) will not function properly with numbers
greater than 13 characters.
Reproduce code:
---------------
-BEGIN SCRIPT-
$string=(string)"Hello Kitty".(string)time();
$hash=md5($string);
$hash=strtoupper($hash); // Easier to
Read
echo("<br>1Hash is '$hash'<br>");
settype($hash, "string");
echo("<br>2Hash is '$hash'<br>");
$hash=base_convert($hash, '16', '10'); // Flick the string
from hex
to dec
echo("<br>3Hash is '$hash'<br>");
$hash=base_convert($hash, '10', '16'); $hash=strtoupper($hash);
echo("<br>4Hash is '$hash'<br>"); // Flick the string back
$hash=strtoupper($hash); // Easier to
read
echo("<br>5Hash is '$hash'<br>");
-END SCRIPT-
Expected result:
----------------
I can't show the exact expected number, as my MS Calc in hex mode can't
handle this number, but it's pretty obvious that all the trailing 0's
are wrong.
Actual result:
--------------
Here is the output text:
1Hash is '9789A9C80C9BFB6B40AD83670F14D64A'
2Hash is '9789A9C80C9BFB6B40AD83670F14D64A'
3Hash is '201428215609899446868600620602402480202'
4Hash is '9789A9C80C9BF8000000000000000000'
5Hash is '9789A9C80C9BF8000000000000000000'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35874&edit=1