C is a powerful language and allows programmer many
operations for bit manipulation. Data can be accessed at
the bit level to make operations and storage more
efficient. As you will see, bit operations can be used to
do many things including setting flags, encrypting and
decrypting images as we will implement in one of the lab
assignments. Bit operations can also be used to efficiently
pack data into a more compressed form. For example, an
entire array of 16 boolean values can be represented by
just 2 bytes of data or an IP address such as 192.168.1.15
can be packed into 32 bits of storage. This can come very
handy in cases where data needs to be transmitted through a
limited bandwidth network or in cases where we simply need
to store data more efficiently for better memory management
in the application. For example, when programming mobile
devices with limited memory, you may want to work at the
bit level to make things more efficient and save memory.
Also understanding bit operations can be useful in writing
device drivers and many other low level applications. First
we will discuss the bit shift operations.
Comments
Leave a comment