How can I convert an Int to a BitArray ?

  • Thread starter Thread starter Marc Lefebvre
  • Start date Start date
M

Marc Lefebvre

How can I convert an Int to a BitArray ?

Or

How can I format an Int to a binairy string ?


Thank's

Marc Lefebvre
 
Marc Lefebvre said:
How can I convert an Int to a BitArray ?
The simplist way I can think of is just to using the int[] overload,
something like
int myInt;
int[] ints = { myInt };
BitArray array = new BitArray(ints);

should do the basics.
Or

How can I format an Int to a binairy string ?
Hrmm, I assume you mean the 01000111 style strings? I don't know of a format
specifier that can display in that format (I could be wrong). If you have to
do it manually you'll probably have to create either an AND loop to check
bit positions or build a lookup table at the byte level.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top