BINARY CONVERSION
Computers work with data, which, to them, is more than a string of symbols.
These symbols are letters, numbers, other characters, can be pictures and
graphs. Inside the computer, all this data is represented in the form the
computer will understand (in the computer’s own codes).
These codes are based on two symbols only – the digits 0 and 1. The digits (
0 and 1) are also used in the base two (binary) number system. They
are given names bits short for binary digits
Computers use a common code called American Standard Code for
Information Interchange (ASCII). An ASCII code is an 8-bit character
code. A convenient grouping of bits inside a computer is in sets of 8 bits. A
set of eight bits is called a byte. A byte can store an ASCII character with
only one bit left.
Note:
1 bit = a single digit, either 1 or 0
8 bits = 1 byte, a combination of 1's and 0's
1024 Bytes = 1 KB (kilobyte)
1024 Kilobytes = 1 MB (megabyte)
1024 Megabytes = 1 GB (gigabyte)
Or
Bytes make up Kilobytes of 1024
which make up Megabytes of 1024 X 1024
which make up Gigabytes of 1024 X 1024 X 1024
ASCII characters and their binary equivalent are shown below.
Binary ASCII Binary ASCII Binary ASCII
Code Characte code Character code Characte
r r
0010000 SPACE 0100000 @ 011000 `
0 0 00
0010000 ! 0100000 A 011000 a
1 1 01
0010001 “ 0100001 B 011000 b
0 0 10
0010001 # 0100001 C 011000 c
1 1 11
0010010 $ 0100010 D 011001 d
0 0 00
Base-10 to base-2 conversions(Decimal to Binary)
To convert from a base-10 integer numeral to its base-2 (binary) equivalent,
the number is divided by two, and the remainder is 0 if the number is
divisible by 2 otherwise 1. The (integer) result is again divided by two and
the remainder is saved. This process repeats until the result of further
division becomes zero.
For example, 11810, in binary, is:
Operatio Remaind
n er
118 ÷ 2 =
0
59
59 ÷ 2 =
1
29
29 ÷ 2 =
1
14
14 ÷ 2 =
0
7
7÷2=3 1
3÷2=1 1
1÷2=0 1
Reading the sequence of remainders from the bottom up gives the binary
numeral 11101102.
Base-2 to base-10 conversions(Binary to decimal)
To convert binary to decimal, assign a weight to each bit, multiplying each
bit's value (0 or 1) by its weight, and then add the totals. For example, here's
how 217 is represented as 11011001 in binary:
NB: Remember our bible for binary conversion
Addition
Adding unsigned numbers
Addition is done exactly like adding decimal numbers, except
that you have only two digits (0 and 1). The only number facts to
remember are that
0+0 = 0, with no carry,
1+0 = 1, with no carry,
0+1 = 1, with no carry,
1+1 = 0, and you carry a 1.
so to add the numbers 0610=01102 and 0710=01112
(answer=1310=11012) we can write out the calculation (the
results of any carry is shown along the top row, in italics).
Unsigned
Decimal
Binary
1 (carry) 110 (carry)
06 0110
+07 +0111
13 1101
The only difficulty adding unsigned numbers occurs when you
add numbers that are too large. Consider 13+5.
Unsigned
Decimal
Binary
0 (carry) 1101 (carry)
13 1101
+05 +0101
18 10010