0
$\begingroup$

Does Mathematica have a build in way to convert a list of numbers into a list of binary numbers? If not how can this be accomplished?

$\endgroup$

closed as off-topic by wxffles, Karsten 7., bbgodfrey, ubpdqn, Bob Hanlon Feb 23 '15 at 3:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – wxffles, Karsten 7., bbgodfrey, ubpdqn, Bob Hanlon
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ There's BaseForm and IntegerDigits. $\endgroup$ – wxffles Feb 22 '15 at 19:21
  • $\begingroup$ I think you should explain more clearly what exactly you mean with "list of binary numbers". You probably want to explain what you want to do with such a list... $\endgroup$ – Albert Retey Feb 22 '15 at 20:04
3
$\begingroup$
list = RandomInteger[{0, 100}, 10]

{65, 84, 31, 23, 72, 64, 29, 78, 43, 87}

BaseForm[#, 2] & /@ list

enter image description here

IntegerDigits[#, 2] & /@ list

{{1, 0, 0, 0, 0, 0, 1}, {1, 0, 1, 0, 1, 0, 0}, {1, 1, 1, 1, 1}, {1, 0, 1, 1, 1}, {1, 0, 0, 1, 0, 0, 0}, {1, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 0, 1}, {1, 0, 0, 1, 1, 1, 0}, {1, 0, 1, 0, 1, 1}, {1, 0, 1, 0, 1, 1, 1}}

FromDigits /@ %

{1000001, 1010100, 11111, 10111, 1001000, 1000000, 11101, 1001110, \ 101011, 1010111}

$\endgroup$
  • 1
    $\begingroup$ BaseForm and IntegerDigits are both listable. $\endgroup$ – Karsten 7. Feb 22 '15 at 21:40
  • $\begingroup$ @Karsten7. - Good point. $\endgroup$ – Bob Hanlon Feb 23 '15 at 1:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.