# How can I transform a list of binary digits into integers?

I want to transform a list of binary digits into integers. With the Table function, I produce four lists of binary digits of length 32. Then I tried to turn these lists into integers, but it didn't work. Any suggestions?

Table[b[i] = 1, {i, 0, 32}];
Table[b[k] = b[i + j] = Mod[(b[i + j - 5] + b[i + j - 32]), 2], {i, 32, 35}, {j, 0, 31}]
FromDigits[{b[k]}, 2]


Using more or less your approach, I use RandomChoice to create some "binary numbers". Next you can use FromDigits and map it on this list.

FromDigits[#, 2] & /@ RandomChoice[{0, 1}, {4, 32}]


Edit: I assumed these "binary" numbers to be random. If you want to use it for the numbers you created, just map it on those. My RandomChoice produces numbers of the same format.

• great - you are welcome. And make sure you understand Map (or just /@) well, that's very useful Jan 21, 2013 at 13:01
• Just for fun. FromDigits[#, 2] & /@ randomChoice == (Fold[ 2 #1 + #2 &, 0, #] & /@ randomChoice) Jan 21, 2013 at 17:37
• @TomD - nice one, it took a bit for me to understand the syntax... Jan 21, 2013 at 18:25

You can use

BaseForm[number, base]


and just run every number through the command.

Example:
BaseForm[2^^1101101,2]

• What if I have 10000 numbers? Jan 21, 2013 at 12:37
• @user5484 You would then use Map or it's shortform /@. Jan 21, 2013 at 13:03