Bit and Byte problem

Discussion in 'C Programming' started by cjw, Oct 17, 2003.

  1. cjw

    cjw Guest

    I need to read an 'unsigned char' array and save it as a bit array
    (values are only 0s or 1s). When processing, have to do math
    operations such as summing up the values etc. Pl let me know an
    efficient way of doing this.
    cjw
     
    cjw, Oct 17, 2003
    #1
    1. Advertising

  2. Greetings.

    In article <>, cjw wrote:
    > I need to read an 'unsigned char' array and save it as a bit array
    > (values are only 0s or 1s). When processing, have to do math
    > operations such as summing up the values etc. Pl let me know an
    > efficient way of doing this.


    Given your e-mail address and the nature of the query, I presume this is a
    homework problem. Fortunately, it's not too hard to solve if you read up
    on C's bit-shifting operators (<< and >>). Once you've done so, try
    writing the program, and if you need help, send another post with your code
    and a description of the problem.

    Regards,
    Tristan

    --
    _
    _V.-o Tristan Miller [en,(fr,de,ia)] >< Space is limited
    / |`-' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= <> In a haiku, so it's hard
    (7_\\ http://www.nothingisreal.com/ >< To finish what you
     
    Tristan Miller, Oct 17, 2003
    #2
    1. Advertising

  3. cjw

    Ravi Uday Guest

    (cjw) wrote in message news:<>...
    > I need to read an 'unsigned char' array and save it as a bit array
    > (values are only 0s or 1s). When processing, have to do math
    > operations such as summing up the values etc. Pl let me know an
    > efficient way of doing this.
    > cjw


    What you mean by bit array !! Is it 8 bits in 1 byte you call as array
    ??
    Well, an array is composed of bytes of type the array points to and
    each
    byte is composed of 8 bits. Bit values help to represent the value in
    that byte to read and process them.
    Define your problem or post snippet of your compilable code in order
    to reply to your mail

    - Ravi
     
    Ravi Uday, Oct 17, 2003
    #3
  4. (Ravi Uday) wrote:

    > (cjw) wrote in message news:<>...
    >> I need to read an 'unsigned char' array and save it as a bit array
    >> (values are only 0s or 1s). When processing, have to do math
    >> operations such as summing up the values etc. Pl let me know an
    >> efficient way of doing this.
    >> cjw

    >
    >What you mean by bit array !! Is it 8 bits in 1 byte you call as array
    >??
    >Well, an array is composed of bytes of type the array points to and


    No.
    An array is a contiguous set of objects of a particular type.
    An array object doesn't point to anything, though it decays into a
    pointer to its first element in value contexts.

    >each
    >byte is composed of 8 bits.


    No.
    A byte is /at least/ eight bits in width.

    >Bit values help to represent the value in
    >that byte to read and process them.


    Value bits represent the value of an object. Padding bits don't.

    >Define your problem or post snippet of your compilable code in order
    >to reply to your mail


    Seconded.
    --
    Irrwahn
    ()
     
    Irrwahn Grausewitz, Oct 17, 2003
    #4
  5. cjw

    Ravi Uday Guest

    Irrwahn Grausewitz <> wrote in message news:<>...
    > (Ravi Uday) wrote:
    >
    > > (cjw) wrote in message news:<>...
    > >> I need to read an 'unsigned char' array and save it as a bit array
    > >> (values are only 0s or 1s). When processing, have to do math
    > >> operations such as summing up the values etc. Pl let me know an
    > >> efficient way of doing this.
    > >> cjw

    > >
    > >What you mean by bit array !! Is it 8 bits in 1 byte you call as array
    > >??
    > >Well, an array is composed of bytes of type the array points to and

    >
    > No.
    > An array is a contiguous set of objects of a particular type.
    > An array object doesn't point to anything, though it decays into a
    > pointer to its first element in value contexts.
    >

    Really .. Clever !

    > >each
    > >byte is composed of 8 bits.

    >
    > No.
    > A byte is /at least/ eight bits in width.
    >
    > >Bit values help to represent the value in
    > >that byte to read and process them.

    >
    > Value bits represent the value of an **object** oh. Padding bits don't. -> Yes i forgot about that :)
    >
    > >Define your problem or post snippet of your compilable code in order
    > >to reply to your mail

    >
    > Seconded.


    Mmmm..
     
    Ravi Uday, Oct 20, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter
    Replies:
    3
    Views:
    734
    Michael Borgwardt
    Aug 5, 2004
  2. Replies:
    3
    Views:
    1,802
    Timothy Bendfelt
    Jan 19, 2007
  3. Replies:
    15
    Views:
    768
    Rod Pemberton
    Apr 28, 2006
  4. Replies:
    9
    Views:
    1,009
    Juha Nieminen
    Aug 22, 2007
  5. Jeff.M
    Replies:
    6
    Views:
    186
    Lasse Reichstein Nielsen
    May 4, 2009
Loading...

Share This Page