Shop OBEX P1 Docs P2 Docs Learn Events
(OT) Maths Question — Parallax Forums

(OT) Maths Question

ArchiverArchiver Posts: 46,084
edited 2000-08-16 04:48 in General Discussion
Sorry about bothering every one with this but it's Late (Here) and I need to
work it out

I'm just wondering if any one could help me with a formula to do the
following :

I have 6 Bits of info that I have assigned 6 numbers eg 1,2,4,8,16,32,

I want to be able to have any combination of the Bits and then pass the
single number to a program
and work out via a formula what the original combination of Bits was.

Is there an easy way of working this one out ?

Any assistance would be greatly appreciated

Dean Stevenson


Email dean@i...

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-08-15 19:46
    Dean:
    I don't understand your problem description.

    Ray McArthur

    Original Message
    From: Dean Stevenson <dean@i...>
    To: <basicstamps@egroups.com>
    Sent: Tuesday, August 15, 2000 8:45 AM
    Subject: [noparse][[/noparse]basicstamps] (OT) Maths Question


    > Sorry about bothering every one with this but it's Late (Here) and I need
    to
    > work it out
    >
    > I'm just wondering if any one could help me with a formula to do the
    > following :
    >
    > I have 6 Bits of info that I have assigned 6 numbers eg 1,2,4,8,16,32,
    >
    > I want to be able to have any combination of the Bits and then pass the
    > single number to a program
    > and work out via a formula what the original combination of Bits was.
  • ArchiverArchiver Posts: 46,084
    edited 2000-08-15 20:16
    not exactly sure about the problem, however, it would seem to me that you
    could use the difference between the numbers to determine the initial bit
    pattern?

    Original Message
    From: rjmca [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=H3LxBgAHN8_E-vplj2-mv3gtX2GLc2XnFO-9UdhajsJpntSetYSG0NWx0r7xRuIFk1FPEeiPseaCgQ]rjmca@w...[/url
    Sent: Tuesday, August 15, 2000 1:46 PM
    To: basicstamps@egroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] (OT) Maths Question


    Dean:
    I don't understand your problem description.

    Ray McArthur

    Original Message
    From: Dean Stevenson <dean@i...>
    To: <basicstamps@egroups.com>
    Sent: Tuesday, August 15, 2000 8:45 AM
    Subject: [noparse][[/noparse]basicstamps] (OT) Maths Question


    > Sorry about bothering every one with this but it's Late (Here) and I need
    to
    > work it out
    >
    > I'm just wondering if any one could help me with a formula to do the
    > following :
    >
    > I have 6 Bits of info that I have assigned 6 numbers eg 1,2,4,8,16,32,
    >
    > I want to be able to have any combination of the Bits and then pass the
    > single number to a program
    > and work out via a formula what the original combination of Bits was.
  • ArchiverArchiver Posts: 46,084
    edited 2000-08-15 20:23
    From what I understand:

    He wants to have 8 bits 1,2,4,8,16,32,64,128 and combine them into a single
    number to send (such as 43). On the other end he wants to receive the 43
    and have a function tell him that it was the bits of 32, 8, 2, and 1. I
    know a very "dirty" way to do this in Visual Basic, but I'm sure there is a
    better Stamp solution. I'm looking forward to seeing the answer as well.

    Shawn

    Original Message
    From: rjmca [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=0nKY_1Zu9Dn_m278Hyhe1wu-B3Y4JfX1nUmTCz4j5k-ALcxZm8yc1vErRRb9YO_-vZ8OJcGT6u08TmJ2-A]rjmca@w...[/url
    Sent: Tuesday, August 15, 2000 11:46 AM
    To: basicstamps@egroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] (OT) Maths Question


    Dean:
    I don't understand your problem description.

    Ray McArthur

    Original Message
    From: Dean Stevenson <dean@i...>
    To: <basicstamps@egroups.com>
    Sent: Tuesday, August 15, 2000 8:45 AM
    Subject: [noparse][[/noparse]basicstamps] (OT) Maths Question


    > Sorry about bothering every one with this but it's Late (Here) and I need
    to
    > work it out
    >
    > I'm just wondering if any one could help me with a formula to do the
    > following :
    >
    > I have 6 Bits of info that I have assigned 6 numbers eg 1,2,4,8,16,32,
    >
    > I want to be able to have any combination of the Bits and then pass the
    > single number to a program
    > and work out via a formula what the original combination of Bits was.
  • ArchiverArchiver Posts: 46,084
    edited 2000-08-15 20:37
    On Tue, 15 Aug 2000, Hendricks, Shawn wrote:

    > >From what I understand:
    >
    > He wants to have 8 bits 1,2,4,8,16,32,64,128 and combine them into a single
    > number to send (such as 43). On the other end he wants to receive the 43
    > and have a function tell him that it was the bits of 32, 8, 2, and 1. I
    > know a very "dirty" way to do this in Visual Basic, but I'm sure there is a
    > better Stamp solution. I'm looking forward to seeing the answer as well.

    It's all represented that way internally. If you want to look at
    individual bits, you'd use a bit and function

    bytevalue&1 (will be 0 or 1)
    bytevalue&2 (will be 0 or 2)
    bytevalue&4 (will be 0 or 4)

    a cheap way to do this would be something like

    loop:

    if (bytevalue & (1 << i)) = 0 then bitnotset
    '
    ' at this point the ith bit in bytevalue is high,
    ' so do soemthing with it.
    '

    bitnotset:

    i = (i+1)//8

    goto loop:


    Combining multiple 'bit' variables into a byte / word for transmission
    isn't particularly useful - it's already represented that way internally.


    Sean T. Lamont, CTO / Chief NetNerd, Abstract Software, Inc. (ServNet)
    Seattle - Bellingham - Vancouver - Portland - Everett - Tacoma - Bremerton
    email: lamont@a... WWW: http://www.serv.net
    "...There's no moral, it's just a lot of stuff that happens". - H. Simpson
  • ArchiverArchiver Posts: 46,084
    edited 2000-08-16 00:04
    I believe you just add the numbers together to transmit (eg you may
    have a bit sequence of 001010 = 2 + 8 = 10). At the other end you use
    the AND command with 1,2,4,8,16,32 to see if the bit is high or low.

    Grant McPherson
    www.ozsonic.com


    --- In basicstamps@egroups.com, "Production Technology, Inc."
    <FIXEMERD@N...> wrote:
    > not exactly sure about the problem, however, it would seem to me
    that you
    > could use the difference between the numbers to determine the
    initial bit
    > pattern?
    >
    >
    Original Message
    > From: rjmca [noparse][[/noparse]mailto:rjmca@w...]
    > Sent: Tuesday, August 15, 2000 1:46 PM
    > To: basicstamps@egroups.com
    > Subject: Re: [noparse][[/noparse]basicstamps] (OT) Maths Question
    >
    >
    > Dean:
    > I don't understand your problem description.
    >
    > Ray McArthur
    >
    >
    Original Message
    > From: Dean Stevenson <dean@i...>
    > To: <basicstamps@egroups.com>
    > Sent: Tuesday, August 15, 2000 8:45 AM
    > Subject: [noparse][[/noparse]basicstamps] (OT) Maths Question
    >
    >
    > > Sorry about bothering every one with this but it's Late (Here)
    and I need
    > to
    > > work it out
    > >
    > > I'm just wondering if any one could help me with a formula to do
    the
    > > following :
    > >
    > > I have 6 Bits of info that I have assigned 6 numbers eg
    1,2,4,8,16,32,
    > >
    > > I want to be able to have any combination of the Bits and then
    pass the
    > > single number to a program
    > > and work out via a formula what the original combination of Bits
    was.
  • ArchiverArchiver Posts: 46,084
    edited 2000-08-16 04:19
    So was his question just about binary math??? or was he looking for an
    encoding algorithem*, and we did not understand his question?!?\


    -Edward Kindler
  • ArchiverArchiver Posts: 46,084
    edited 2000-08-16 04:48
    My question was more to do with trying to find a decoding algorithm,

    Rather than taking up a lot of space having to do branching IF statements
    with every possible
    combination,

    I think that I have worked out a way to reduce the number of IF THEN
    statements,

    I will post the code when I get it debugged

    Many thanks for the help

    Dean Stevenson


    Original Message
    From: <RiffRaff82@a...>
    To: <basicstamps@egroups.com>
    Sent: Wednesday, August 16, 2000 1:19 PM
    Subject: Re: [noparse][[/noparse]basicstamps] Re: (OT) Maths Question


    > So was his question just about binary math??? or was he looking for an
    > encoding algorithem*, and we did not understand his question?!?\
    >
    >
    > -Edward Kindler
    >
    >
    >
    >
Sign In or Register to comment.