#42694 [NEW]: decbin() is not returning the correct value
| From: | carrotcake1029 at gmail dot com | Date: | Tue, 18 Sep 2007 07:08:33 +0000 |
| Subject: | #42694 [NEW]: decbin() is not returning the correct value | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-117618@lists.php.net to get a copy of this message | ||
From: carrotcake1029 at gmail dot com
Operating system: Windows Vista Home Premium
PHP version: 5.2.4
PHP Bug Type: *Encryption and hash functions
Bug description: decbin() is not returning the correct value
Description:
------------
I wrote my own little function that can take numbers and make turn them
into numbers of other bases. When I ran a few tries with binary, I began
to notice that PHP's decbin() was not matching up with mine. Easily
proven, mine was correct.
Reproduce code:
---------------
echo dec2base(4728937489, 2) . "\n";
echo decbin(4728937489);
function dec2base($int, $base)
{
while ($int >= 1)
{
$ret .= $int % $base;
$int = $int / $base;
}
return strrev($ret);
}
Expected result:
----------------
100011001110111011101110000010001
100011001110111011101110000010001
Actual result:
--------------
100011001110111011101110000010001
11001110111011101110000010001
--
Edit bug report at http://bugs.php.net/?id=42694&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42694&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42694&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42694&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42694&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=42694&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42694&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42694&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42694&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42694&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42694&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=42694&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=42694&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42694&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42694&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42694&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42694&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42694&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42694&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42694&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42694&r=mysqlcfg