# World of Bits and Bytes

Recently, I have realized that no matter how much C, C++ or other high level languages you know it all comes down to bit and bytes view of program.
I started realizing that after all it’s not that easy to actually think and write in bit/byte manipulation. This is my attempt to learn and be more comfortable about thinking in bit/bytes.

### Basics

Introduction here

### Bit Fields

 1struct date-struct {
2BYTE day   : 5,   // 1 to 31
3     month : 4,   // 1 to 12
4     year  : 14;  // 0 to 9999
5} date
6
7|0 0 0 0 0 0 0 0|0 0 0 0 0 0 0 0|0 0 0 0 0 0 0 0 |
8  |                           |       |         |
9  +------ year ---------------+ month +-- day --+
10
11date.day = 12;
12dateptr = &date;
13dateptr->year = 1852;


Basics of Binary Arithmetic

### Problems

#### How set a single bit in a byte?

For e.g In byte 0000 1000 set bit no 6 will produce 0100 1000
(Remember bit number starts with 0-7)

#### How to unset single bit in a byte?

For e.g In byte 0100 1000 unset bit no 6 will produce 0000 1000
(Remember bit number starts with 0-7)