Advertisement
ipsBruno

(Pawn) bin2dec

Oct 11th, 2013
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.26 KB | None | 0 0
  1. /*
  2. * bin to dec
  3. * converts binary string to decimal number
  4. * author: ipsBruno
  5. */
  6.  
  7. bin2dec(n[]) {
  8.  
  9.     static c, l, j;
  10.  
  11.     c = 0;
  12.  
  13.     for(l = strlen(n) - 1, j = l  ; j > -1 ; j--) {
  14.         if(n[j] == '1') c +=  (1 << (l-j));
  15.     }
  16.  
  17.     return c;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement