|
-
Jul 2nd, 2003, 03:14 AM
#1
Thread Starter
Member
Comparison binary in .NET
Dear All
I like to take an integer value such as 3000 and convert to binary mode such as "3000=101110111000" and compare every bit and find-out which of the bits is set to "1" and which of the bits set to "0"
Many Thanks for any reply
salih
-
Jul 2nd, 2003, 04:23 AM
#2
Try this to get you started.
VB Code:
Dim i As Integer = 3000
Dim str As String = Convert.ToString(i, 2)
Debug.WriteLine(str)
This world is not my home. I'm just passing through.
-
Jul 2nd, 2003, 04:33 AM
#3
next step
Here's the rest of what you want. I'm not sure that the For loop is the smartest way to do it, but its all I can think of at the moment...
VB Code:
Dim i As Integer = 3000
Dim str As String = Convert.ToString(i, 2)
Debug.WriteLine(str)
Dim find As Integer
For find = Len(str) To 1 Step -1
If Mid(str, find, 1) = "1" Then
Debug.WriteLine("Bit " & Len(str) - find + 1 & " is set.")
End If
Next
This world is not my home. I'm just passing through.
-
Jul 2nd, 2003, 06:55 AM
#4
I wonder how many charact
You should look into the BitVector32 class.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|