Options

Convert Integer to BitArray

mikmik Member Posts: 79
Hi, I'm not able to figure out how I can convert an integer to an BitArray

Example:
8 (0,0,0,1,0,0,0,0)
3 (1,1,0,0.0.0.0.0)

I tried to Convert the Integer to a Byte[] in dotnet. This Byte[] I want to convert into an BitArray.

This Code is wrong and I can't even compile it.

Int := 8;
str := FORMAT(Int);
SystemArray := SystemConvert.FromBase64String(str);
BitArray := BitArray.BitArray(SystemArray);

FOR i := 0 TO BitArray.Length - 1  DO BEGIN
  MESSAGE(FORMAT(BitArray.Get(i)));
END;

I also tried ...
SystemArray := SystemArray.CreateInstance(GETDOTNETTYPE(SystemByte),4);

Help would be great :)

With kind regards
mik

Best Answer

Answers

  • Options
    Peter+is1Peter+is1 Member Posts: 174
    Hi,

    Can you provide the code and variables (declarations) you use?
    I cannot re-create your scenario without those...
    \\
    The truth exists in seven versions.
Sign In or Register to comment.