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/
- References:
- Converting Binary form to a desired array
- From: athlonspell <athlonspell@yahoo.ca>
- Converting Binary form to a desired array