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: [mg76015] Re: [mg75980] Converting Binary form to a desired array
  • From: "Patrick Scheibe" <mai99dnn at studserv.uni-leipzig.de>
  • Date: Mon, 14 May 2007 05:56:13 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <200705140745.DAA23104@smc.vnet.net>


Hi,

I would do it like this

ToBinary[number_Integer] := ToBinary[IntegerDigits[number, 2]];
ToBinary[{b_}] = {b};
ToBinary[{b_, rest___}] := Prepend[ToBinary[{rest}], 2^Length[{rest}]*b];


ToBinary[212] = {128, 64, 0, 16, 0, 4, 0, 0}

Cheers
Patrick


Am 14.05.2007, 09:45 Uhr, schrieb athlonspell <athlonspell at yahoo.ca>:

> 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



-- 
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/


  • Prev by Date: Re: How to get sqrt(Year^2)===Year?
  • Next by Date: Re: Package Help in Mathematica 6
  • Previous by thread: Converting Binary form to a desired array
  • Next by thread: Re: Converting Binary form to a desired array