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.
 
Back
Top