Convert array of Bits to Byte - "design.wonk" - May 6 23:42:29 2008
I have an array of three bits (based on an object being in range on a
combination of three IR sensors). Is there a graceful way to convert
this 3-bit array to a single byte value? I have written a function
that returns a value of 0 to 7 based on the status of the bits in the
array, but it uses a long and awkward series of If Then Else looping.
I was wondering if there is a simpler way to do this with version 6.1.
thanks
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )
Re: Convert array of Bits to Byte - Andrew Porrett - May 7 0:36:21 2008
v = bit1 * 4 + bit2 * 2 + bit3 ?
At 11:42 PM 5/6/2008, design.wonk wrote:
>I have an array of three bits (based on an object being in range on a
>combination of three IR sensors). Is there a graceful way to convert
>this 3-bit array to a single byte value? I have written a function
>that returns a value of 0 to 7 based on the status of the bits in the
>array, but it uses a long and awkward series of If Then Else looping.
> I was wondering if there is a simpler way to do this with version 6.1.
>
>thanks
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )
Re: Convert array of Bits to Byte - "design.wonk" - May 7 9:17:00 2008
Wow, that was so logical. I guess that I was thinking that it had to
be more complicated.
thanks
--- In o...@yahoogroups.com, Andrew Porrett
wrote:
>
> v = bit1 * 4 + bit2 * 2 + bit3 ?
>
> At 11:42 PM 5/6/2008, design.wonk wrote:
> >I have an array of three bits (based on an object being in range on a
> >combination of three IR sensors). Is there a graceful way to convert
> >this 3-bit array to a single byte value? I have written a function
> >that returns a value of 0 to 7 based on the status of the bits in the
> >array, but it uses a long and awkward series of If Then Else looping.
> > I was wondering if there is a simpler way to do this with version
6.1.
> >
> >thanks
>
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )Re: Convert array of Bits to Byte - tuandung248 - May 7 10:10:50 2008
if you want it faster:
dim v as oByte
v = bit1;
v.Lshift(1);
v = v Or bit2;
v.Lshift(1);
v = v Or bit3;
--- In o...@yahoogroups.com, "design.wonk"
wrote:
>
> Wow, that was so logical. I guess that I was thinking that it had to
> be more complicated.
>
> thanks
>
> --- In o...@yahoogroups.com, Andrew Porrett wrote:
> >
> > v = bit1 * 4 + bit2 * 2 + bit3 ?
> >
> > At 11:42 PM 5/6/2008, design.wonk wrote:
> > >I have an array of three bits (based on an object being in range on a
> > >combination of three IR sensors). Is there a graceful way to convert
> > >this 3-bit array to a single byte value? I have written a function
> > >that returns a value of 0 to 7 based on the status of the bits in the
> > >array, but it uses a long and awkward series of If Then Else looping.
> > > I was wondering if there is a simpler way to do this with version
> 6.1.
> > >
> > >thanks
>
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )Re: Convert array of Bits to Byte - "design.wonk" - May 7 14:00:31 2008
Yes,
That is the way that I had seen it done before - but I couldn't
remember exactly how it was done.
thanks
--- In o...@yahoogroups.com, "tuandung248"
wrote:
>
> if you want it faster:
>
> dim v as oByte
> v = bit1;
> v.Lshift(1);
> v = v Or bit2;
> v.Lshift(1);
> v = v Or bit3;
>
> --- In o...@yahoogroups.com, "design.wonk" wrote:
> >
> > Wow, that was so logical. I guess that I was thinking that it had to
> > be more complicated.
> >
> > thanks
> >
> >
> >
> > --- In o...@yahoogroups.com, Andrew Porrett wrote:
> > >
> > > v = bit1 * 4 + bit2 * 2 + bit3 ?
> > >
> > > At 11:42 PM 5/6/2008, design.wonk wrote:
> > > >I have an array of three bits (based on an object being in
range on a
> > > >combination of three IR sensors). Is there a graceful way to
convert
> > > >this 3-bit array to a single byte value? I have written a function
> > > >that returns a value of 0 to 7 based on the status of the bits
in the
> > > >array, but it uses a long and awkward series of If Then Else
looping.
> > > > I was wondering if there is a simpler way to do this with version
> > 6.1.
> > > >
> > > >thanks
> > >
>
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )Re: Re: Convert array of Bits to Byte - Andrew Porrett - May 8 0:16:47 2008
Why do you think it will be faster?
At 10:10 AM 5/7/2008, tuandung248 wrote:
>if you want it faster:
>
>dim v as oByte
>v = bit1;
>v.Lshift(1);
>v = v Or bit2;
>v.Lshift(1);
>v = v Or bit3;
>
>--- In o...@yahoogroups.com, "design.wonk"
wrote:
> >
> > Wow, that was so logical. I guess that I was thinking that it had to
> > be more complicated.
> >
> > thanks
> >
> >
> >
> > --- In o...@yahoogroups.com, Andrew Porrett wrote:
> > >
> > > v = bit1 * 4 + bit2 * 2 + bit3 ?
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )