Re: Converting Binary form to a desired array
- To: mathgroup at smc.vnet.net
 - Subject: [mg76006] Re: Converting Binary form to a desired array
 - From: Szabolcs <szhorvat at gmail.com>
 - Date: Mon, 14 May 2007 05:51:36 -0400 (EDT)
 - Organization: University of Bergen
 - References: <f2959d$n0n$1@smc.vnet.net>
 
athlonspell wrote:
> Hello,
> 
> I have this:
> 
>>  BaseForm[212,2] = 10100 
> 
> Now, I am trying to achieve this output from above:
> 
>>  {2^4, 0, 2^2, 0, 0}
> 
> How do I go about do this? 
> 
> Thank you,
> Sharon
> 
Reverse@MapIndexed[#1 Superscript[2, First@#2] &,
   Reverse@IntegerDigits[212, 2]]
You may want to replace Superscript by Power if you need usable numbers 
in the list (but then 8 will be displayed instead of 2^3).