Convert Integer to BitArray

mik
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.
I also tried ...
Help would be great
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
0
Best Answer
-
Hi,
I managed it by myself ... (everyone feel free to post a better solution)Int Integer SystemConvert DotNet System.Convert.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' SystemString DotNet System.String.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' str Text
Int := 8; SystemString := SystemConvert.ToString(Int,2); str := SystemString; SystemString := PADSTR('',8-STRLEN(SystemString),'0') + str; MESSAGE(SystemString);
With kind regards
mik6
Answers
-
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.0 -
Hi,
I managed it by myself ... (everyone feel free to post a better solution)Int Integer SystemConvert DotNet System.Convert.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' SystemString DotNet System.String.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' str Text
Int := 8; SystemString := SystemConvert.ToString(Int,2); str := SystemString; SystemString := PADSTR('',8-STRLEN(SystemString),'0') + str; MESSAGE(SystemString);
With kind regards
mik6
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions