469,646 Members | 1,178 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

BitWise split?

Hi,

Is there any easy way to split a bitwise value, for sample 127 to an array
into 1, 2, 4, 8, 16, 32, 64?

Regards
Fredrik Melin
Nov 21 '05 #1
6 1639
Nevermind, found it easy to do it in a FOR loop.

"Fredrik Melin" <me*@no-spam.dacsa-remove-this.net> wrote in message
news:OE**************@TK2MSFTNGP10.phx.gbl...
Hi,

Is there any easy way to split a bitwise value, for sample 127 to an array
into 1, 2, 4, 8, 16, 32, 64?

Regards
Fredrik Melin

Nov 21 '05 #2
Frederik,

Better is in my opinion when you found it yourself to change the subject,
now it can look as an addition. However I am glad you sand this of course
and that you found your solution.

Cor

"Fredrik Melin" <me*@no-spam.dacsa-remove-this.net>
Nevermind, found it easy to do it in a FOR loop.

"Fredrik Melin" <me*@no-spam.dacsa-remove-this.net> wrote in message
news:OE**************@TK2MSFTNGP10.phx.gbl...
Hi,

Is there any easy way to split a bitwise value, for sample 127 to an
array into 1, 2, 4, 8, 16, 32, 64?

Regards
Fredrik Melin


Nov 21 '05 #3
"Fredrik Melin" <me*@no-spam.dacsa-remove-this.net> schrieb:
Is there any easy way to split a bitwise value, for sample 127
to an array into 1, 2, 4, 8, 16, 32, 64?


Why would you "split" 127 to these numbers?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #4
Herfried K. Wagner [MVP] wrote:
"Fredrik Melin" <me*@no-spam.dacsa-remove-this.net> schrieb:
Is there any easy way to split a bitwise value, for sample 127
to an array into 1, 2, 4, 8, 16, 32, 64?

Why would you "split" 127 to these numbers?

bitwise comparison. Alot of flags for API calls work that way.
That way you can pass alot of options with one integer (16 bit
integer=16 options).
--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #5
"C-Services Holland b.v." <cs*@REMOVEcsh4u.nl> schrieb:
Is there any easy way to split a bitwise value, for sample 127
to an array into 1, 2, 4, 8, 16, 32, 64?

Why would you "split" 127 to these numbers?


bitwise comparison. Alot of flags for API calls work that way.
That way you can pass alot of options with one integer (16 bit integer=16
options).


Well, I know that, but I was slightly irritated by the "split" in the
subject.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #6
Hope this can help you but you need to shift with 128 and you never mention
what data type is your array so I use Integer for the example:

Dim arr(128) As Integer
Dim arr1(128 >> 1) As Integer
Dim arr2(128 >> 2) As Integer
Dim arr3(128 >> 3) As Integer
Dim arr4(128 >> 4) As Integer
Dim arr5(128 >> 5) As Integer
Dim arr6(128 >> 6) As Integer
Dim arr7(128 >> 7) As Integer

chanmm

"Fredrik Melin" <me*@no-spam.dacsa-remove-this.net> wrote in message
news:OE**************@TK2MSFTNGP10.phx.gbl...
Hi,

Is there any easy way to split a bitwise value, for sample 127 to an array
into 1, 2, 4, 8, 16, 32, 64?

Regards
Fredrik Melin

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by jas_lx | last post: by
2 posts views Thread by Steve Summit | last post: by
8 posts views Thread by Paul E Collins | last post: by
9 posts views Thread by Christopher Weaver | last post: by
5 posts views Thread by noridotjabi | last post: by
2 posts views Thread by Mark Rae | last post: by
5 posts views Thread by Gigs_ | last post: by
10 posts views Thread by Rob Wilkerson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.