From: sparhawk AT eunet DOT at (Gerhard Gruber) Newsgroups: comp.os.msdos.djgpp Subject: Re: short int and unsigned char Date: Fri, 31 Jul 1998 13:51:16 GMT Organization: EUnet Austria Lines: 47 Message-ID: <35c2cb79.1026327@news.Austria.EU.net> References: <199807302138 DOT XAA10684 AT d1o22 DOT telia DOT com> <35C13C93 DOT 27DEF5B AT hof DOT baynet DOT de> NNTP-Posting-Host: e008.dynamic.vienna.at.eu.net Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 NNTP-Posting-Date: 31 Jul 1998 13:52:01 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Content-Transfer-Encoding: 8bit Precedence: bulk Destination: "Böhme Uwe" From: Gruber Gerhard Group: comp.os.msdos.djgpp Date: Fri, 31 Jul 1998 05:40:04 +0200: >> I wonder how big a short int is (in bits) and if there are anything smaller >> then an unsigned char (1, 2, 4 bits). I also wonder if there is any command >> to read and write a single bit in a variable. >> >> Thanks in advance. > > I don't know weather there are packed bit arrays in ANSI. >But one thing is clear. Even if there are, in most cases it's not very usefull >(with very rare exception)' cause for the iXX processor there is no way to set >a single bit despites the regular way with and(&) and or (|) and so you can do >in C also. >The sizeof operator will allways give you the size of the variable you are >using. >The n'th bit you get by (1<You can set it by var|=(1<You can wipe it by var&=~(1< >So why messing around with bitwise variables. Because you have the advantage that in a debugging session you can print the value of the variable. Using your method, you have to print the value and calculate it by yourself. Also, if you program hardware registers, you can map the bitfields to the register in youse and can adress it quite easy with a variable name. It has advantages. -- Bye, Gerhard email: sparhawk AT eunet DOT at g DOT gruber AT sis DOT co DOT at Spelling corrections are appreciated.