You are here:

C/How to represent a bit in C? details below?

Advertisement


Question
you can represent a byte with a type char and for a word(32 bits) with an int. Is there any way you can represent a single bit in C or in Assembly-with any data type? thank you

Answer
Hello Heni

There is no datatype that is 1 bit long, but there is a way to split a short or int into regions called bit fields. Each bit field can be accessed by its own name. Look at
http://msdn.microsoft.com/en-us/library/yszfawxh%28v=vs.80%29.aspx
and
http://www.cs.cf.ac.uk/Dave/C/node13.html
for a description and example.

Best regards

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Zlatko

Expertise

No longer taking questions.

Experience

No longer taking questions.

Education/Credentials
No longer taking questions.

©2012 About.com, a part of The New York Times Company. All rights reserved.