A **bit** can have only one of two values: 0 or 1. The term bit is a shorted form of **binary digit**. The two values (0 and 1) can also be interpreted as logical values (true/false, yes/no), algebraic signs (+/?) and so on. A group of **eight bits** is commonly called one **byte**, but historically the size of the byte is not strictly defined.

The symbol for bit, as a unit of information, is either simply **bit** (ISO/IEC standard 80000-13 (2008)) or lowercase **b** (IEEE 1541 Standard (2002)). In contrast, the upper case letter **B** is the standard and customary symbol for byte. While the term byte might be ambiguous, you might find the term **octet** as a representation of 8 bits (used in the representation of IP addresses and network protocol parameters).

Computers usually manipulates bits in groups of a fixed sizes, conventionally named **words**. Like the byte, the number of bits in a word also varies with the hardware design, and is typically between 8 and 80 bits, or even more. Nowadays, the most common word size are of 32 or 64 bits.

The lack of human capabilities to think in binary, led to different mapping mechanism: byte, ASCII, hexadecimal and so on. As such, when it comes to a conversion for human use, this is what 8 bits can represent:

- 00000000 – decimal 0
- 00000001 – decimal 1
- 00000010 – decimal 2
- 00000011 – decimal 3
- 00000100 – decimal 4

…….. - 11111110 – decimal 254
- 11111111 – decimal 255

Who said that math is fun? Let’s see several methods that would allow us to convert a decimal into a binary and a binary back into a digital. And let’s start by saying that a decimal number has digits that go from 0 to 9 and that the bytes have the highest value bit at the left and the lowest value at the right (if I lost you already, is the exact same way as a decimal number). Now, each bit in a byte is referred using it’s index number:

- bit 7 – index: 7 (MSB)
- bit 6 – index: 6
- bit 5 – index: 5
- bit 4 – index: 4
- bit 3 – index: 3
- bit 2 – index: 2
- bit 1 – index: 1
- bit 0 – index: 0 (LSB)

where bit 0 is is the lowest value bit (**Lowest Significant Bit** – LSB) and bit 7 is the highest value bit (**Most Significant Bit** – MSB). Let’s see now how we can convert the byte 10101101 into a decimal number. First of all, this byte is represented by position – you will move from right to left and increase the multiplier by the power of two (2). This multiplier is used as the binary format is using the base-2 notation.

- 1st digit from right multiplier 2
^{0}= 1 - 2nd digit from right multiplier 2
^{1}= 2 - 3rd digit from right multiplier 2
^{2}= 4 - 4th digit from right multiplier 2
^{3}= 8 - 5th digit from right multiplier 2
^{4}= 16 - 6th digit from right multiplier 2
^{5}= 32 - 7th digit from right multiplier 2
^{6}= 64 - 8th digit from right multiplier 2
^{7}= 128

Now let’s get back to our binary value – 10101101 – and let’s apply the same logic.

- 1st digit represents the number of 2
^{0}‘s => 1 * 2^{0} - 2nd digit represents the number of 2
^{1}‘s => 0 * 2^{1} - 3rd digit represents the number of 2
^{2}‘s => 1 * 2^{2} - 4th digit represents the number of 2
^{3}‘s => 1 * 2^{3} - 5th digit represents the number of 2
^{4}‘s => 0 * 2^{4} - 6th digit represents the number of 2
^{5}‘s => 1 * 2^{5} - 7th digit represents the number of 2
^{6}‘s => 0 * 2^{6} - 8th digit represents the number of 2
^{7}‘s => 1 * 2^{7}

Considering the above, our digital representation of our byte is the sum of all the values:

(1 * 2^{0}) + (0 * 2^{1}) + (1 * 2^{2}) + (1 * 2^{3}) + (0 * 2^{4}) + (1 * 2^{5}) + (0 * 2^{6}) + (0 * 2^{7}) =

= 1 + 0 + 4 + 8 + 0 + 32 + 0 + 128 =

= 173

Now that we have seen how to convert the byte into a digit, let’s see how we can covert the number 173, into a byte or a binary format. For this, on each bit position you need to see if the bit adds to the total value or if it doesn’t. This time, we will start with the highest bit position value and we will use the division with remainder technique.

Yes, the whole part is 1 and the remainder is 36.

Yes, with the whole part 0 and the remainder 36.

Yes, with the whole part 1 and the remainder 14.

Yes, with the whole part 0 and the remainder 14.

Yes, with the whole part 1 and the remainder 6.

Yes, with the whole part 1 and the remainder 2.

Yes, with the whole part 1 and the remainder 0.

Yes, with the whole part 0 and the remainder 0.

Once I got the remainder 0, I can easily obtain the byte associated with the digit 174, by having the whole part concatenated from right to left. As such, the resulted byte is 10101110.

Both methods can be scaled up for as many bytes, binary digits or digital digits that you might need.