Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Converting Binary form to a desired array

  • To: mathgroup at smc.vnet.net
  • Subject: [mg76064] Re: Converting Binary form to a desired array
  • From: Bill Rowe <readnewsciv at sbcglobal.net>
  • Date: Tue, 15 May 2007 05:06:31 -0400 (EDT)

On 5/14/07 at 5:51 AM, szhorvat at gmail.com (Szabolcs) wrote:

>athlonspell wrote:

>>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?

>Reverse@MapIndexed[#1 Superscript[2, First@#2] &,
>Reverse@IntegerDigits[212, 2]]

Close, but not quite there. Remember Mathematica indexes
starting with 1 but the powers needed will be indexed starting
with 0. So,

Reverse@MapIndexed[#1 Superscript[2, First@#2-1] &,
Reverse@IntegerDigits[212, 2]]

is needed
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Converting Binary form to a desired array
  • Next by Date: weird behavior when plotting multiple functions in 6.0
  • Previous by thread: Re: Converting Binary form to a desired array
  • Next by thread: Re: Converting Binary form to a desired array