Guest User

binaire

a guest
Feb 27th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.17 KB | None | 0 0
  1. <?php
  2.  
  3. $binaire = array(1,0,1,0);
  4. $len = count($binaire) - 1;
  5. $dec = 0;
  6. for($i=$len;$i != 0;$i--)
  7. {
  8.     $dec = $dec + $binaire[$i] * pow(2,$i);
  9. }
  10.  
  11. echo $dec;
  12.  
  13. ?>
Advertisement
Add Comment
Please, Sign In to add comment