note 86129 added to function.decbin

From: Date: Sat, 04 Oct 2008 12:04:51 +0000
Subject: note 86129 added to function.decbin
Groups: php.notes 
Request: Send a blank email to php-notes+get-145045@lists.php.net to get a copy of this message
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

« previous php.notes (#145045) next »