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?
1 Answer
$\begingroup$
$\endgroup$
2
list = RandomInteger[{0, 100}, 10]
{65, 84, 31, 23, 72, 64, 29, 78, 43, 87}
BaseForm[#, 2] & /@ list
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}
-
2$\begingroup$
BaseForm
andIntegerDigits
are both listable. $\endgroup$– Karsten7Commented Feb 22, 2015 at 21:40 -
BaseForm
andIntegerDigits
. $\endgroup$