Bit and Byte problem

C

cjw

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
 
T

Tristan Miller

Greetings.

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
 
R

Ravi Uday

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
 
I

Irrwahn Grausewitz

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.
 
R

Ravi Uday

Irrwahn Grausewitz said:
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 !
No.
A byte is /at least/ eight bits in width.


Value bits represent the value of an **object** oh. Padding bits don't. -> Yes i forgot about that :)


Seconded.

Mmmm..
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top