Re: Converting Binary form to a desired array
- To: mathgroup at smc.vnet.net
- Subject: [mg76069] Re: Converting Binary form to a desired array
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Tue, 15 May 2007 05:09:04 -0400 (EDT)
- Organization: Uni Leipzig
- References: <f2959d$n0n$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
Hi, try toBinary[n_] := Module[{dig, l}, dig = IntegerDigits[n, 2]; l = Length[dig]; Table[HoldForm[2^k] /. k -> i , {i, l - 1, 0, -1}]*dig ] tt=toBinary[212] and backwards with Plus @@ (tt /. HoldForm[a_]:>a) Regards Jens 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 >