|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-09-19 13:13 UTC] smlerman at gmail dot com
[2007-10-02 11:54 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 14:00:01 2025 UTC |
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