What is ....
Kurt Wall
kwall
Wed Feb 8 21:31:19 PST 2006
On Wed, Feb 08, 2006 at 07:14:49PM -0600, Ben Duncan took 17 lines to write:
> In programming C, I have run across the term "bit map". What is it
> and how does one use it ?
A bitmap a byte or byte-range in which information is encoded into
the constituent bits. So, instead of a (for example) C int having a
single unitary value (say, 13), it can contain as much information as
you can encode into the number of bits a C int contains (which would
be 4*2^^8, or 1024 bits).
Bitmaps are an extremely concise and efficient way to pack a lot of
information into a small space. One common example is the UNIX
file permissions, which are constructed from set of three octal
bitmaps:
User Grp Other
001 010 100 Execute
002 020 200 Write
004 040 400 Read
The bitmaps used in this example are octal, but they can also be binary
or hexadecimal.
You treat a bitmap as a range of bits, each bit of which represents a
discrete piece of data. You use a bitmask to access specific bits and
manipulate the bitmap using logical ANDs and ORs.
Kurt
--
Coward, n.:
One who in a perilous emergency thinks with his legs.
-- Ambrose Bierce, "The Devil's Dictionary"
More information about the Linux-users
mailing list