PC Review


Reply
Thread Tools Rate Thread

BitWise split?

 
 
Fredrik Melin
Guest
Posts: n/a
 
      17th Nov 2004
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


 
Reply With Quote
 
 
 
 
Fredrik Melin
Guest
Posts: n/a
 
      17th Nov 2004
Nevermind, found it easy to do it in a FOR loop.

"Fredrik Melin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      17th Nov 2004
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" <(E-Mail Removed)>
> Nevermind, found it easy to do it in a FOR loop.
>
> "Fredrik Melin" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
>>
>>

>
>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      17th Nov 2004
"Fredrik Melin" <(E-Mail Removed)> 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/>
 
Reply With Quote
 
C-Services Holland b.v.
Guest
Posts: n/a
 
      17th Nov 2004
Herfried K. Wagner [MVP] wrote:

> "Fredrik Melin" <(E-Mail Removed)> 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.
 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      17th Nov 2004
"C-Services Holland b.v." <(E-Mail Removed)> 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/>

 
Reply With Quote
 
chanmmn
Guest
Posts: n/a
 
      17th Nov 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bitwise [OR] David Microsoft C# .NET 4 12th Oct 2005 08:03 AM
Bitwise Or and bitwise shifting..... James Dean Microsoft C# .NET 5 22nd Jun 2004 11:29 AM
bitwise alphabesuation Freeware 2 10th Feb 2004 06:53 PM
Bitwise And Justin Starnes Microsoft Excel Programming 1 22nd Jul 2003 05:17 AM
Re: Bitwise Diego Diaz Microsoft Access Queries 0 10th Jul 2003 06:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:18 AM.