From:             chris at acsi dot ca
Operating system: Windows XP Sp2
PHP version:      5.1.1
PHP Bug Type:     Math related
Bug description:  base_convert is off on numbers greater than 13 decimal places

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 bug report at http://bugs.php.net/?id=35874&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=35874&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=35874&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=35874&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=35874&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=35874&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=35874&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=35874&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=35874&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=35874&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=35874&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=35874&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=35874&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=35874&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=35874&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=35874&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=35874&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=35874&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=35874&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=35874&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=35874&r=mysqlcfg

Reply via email to