Guest User

Untitled

a guest
Jul 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.22 KB | None | 0 0
  1. public int BinToDec(bool[] digits)
  2. {
  3.     int result = 0;
  4.     int digitValue = 1;
  5.     for(int x=0; x<digits.Length; x++)
  6.     {
  7.         result += digits[digits.Length - x - 1] ? digitValue : 0;
  8.         digitValue *= 2;
  9.     }
  10.     return result;
  11. }
Add Comment
Please, Sign In to add comment