TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: PETER HAYWOOD
from: HERMAN SCHONFELD
date: 1997-04-30 19:54:00
subject: Re: Bit Fields

PH>Groovy hepcat Rick Bischoff jived with All on 20 Mar 97  10:29:08!
PH>Bit Fields's a cool scene. Dig it!
 RB> Does anyone know how to declare a variable that holds only one bit
PH>of
 RB> information.. (You know only two values (0 or 1)) ???
PH>  In other words, a boolean type? Well, you can't. You can, however,
PH>do one of two things. You could declare an int (or a short or even a
PH>char) and use that for one boolean value. (You could even use the
PH>typedef keyword to create a new BOOL type.) The other thing you could
PH>do is use one int (or short or long or whatever) to hold many boolean
PH>values, then use bitwise AND (&) and OR (|) operators to manipulate
PH>each bit.
This should expand your knowledge abit..
struct  bit_field
  {
        int bit0    : 1;
        int bit1    : 1;
        int bit2    : 1;
        int bit3    : 1;
        int bit4    : 1;
        int bit5    : 1;
        int bit6    : 1;
        int bit7    : 1;
        int bit8    : 1;
        int bit9    : 1;
        int bit10   : 1;
        int bit11   : 1;
        int bit12   : 1;
        int bit13   : 1;
        int bit14   : 1;
        int bit15   : 1;
   } bit_var;
PH>                                                  Wolvaen
... HHeellpp.. II''mm ssttuucckk iinn hhaallff--dduupplleexx.
--- Ezycom V1.48g0 01fd016b
---------------
* Origin: Fox's Lair BBS Bris Aus +61-7-38033908 V34+ Node 2 (3:640/238)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.