| Newsgroups |
php.notes |
| Message-ID |
<[email protected]> |
I think this is the best function. Is almost endlessy (till 2^50 or something)
<?php
function bin($int)
{
$i = 0;
$binair = "";
while($int >= pow(2,$i))
{
$i++;
}
if($i != 0)
{
$i = $i-1; //max i
}
while($i >= 0)
{
if($int - pow(2,$i) < 0)
{
$binair = "0".$binair;
}else{
$binair = "1".$binair;
$int = $int - pow(2,$i);
}
$i--;
}
return $binair;
}
$getal = $_GET['getal'];
echo bin($getal);
?>
----
Server IP: 83.137.20.135
Probable Submitter: 195.241.225.70
----
Manual Page -- http://www.php.net/manual/en/function.decbin.php
Edit -- https://master.php.net/note/edit/86129
Del: integrated -- https://master.php.net/note/delete/86129/integrated
Del: useless -- https://master.php.net/note/delete/86129/useless
Del: bad code -- https://master.php.net/note/delete/86129/bad+code
Del: spam -- https://master.php.net/note/delete/86129/spam
Del: non-english -- https://master.php.net/note/delete/86129/non-english
Del: in docs -- https://master.php.net/note/delete/86129/in+docs
Del: other reasons-- https://master.php.net/note/delete/86129
Reject -- https://master.php.net/note/reject/86129
Search -- https://master.php.net/manage/user-notes.php