#35874 [Opn->Bgs]: base_convert is off on numbers greater than 13 decimal places

From: Date: Tue, 03 Jan 2006 07:52:48 +0000
Subject: #35874 [Opn->Bgs]: base_convert is off on numbers greater than 13 decimal places
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-91373@lists.php.net to get a copy of this message
 ID:               35874
 Updated by:       sniper@php.net
 Reported By:      chris at acsi dot ca
-Status:           Open
+Status:           Bogus
 Bug Type:         Math related
 Operating System: Windows XP Sp2
 PHP Version:      5.1.1
 New Comment:

Never heard about 32bits and some limits there are to it?


Previous Comments:
------------------------------------------------------------------------

[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


Thread (2 messages)

« previous php.bugs (#91373) next »