0% found this document useful (0 votes)
5 views

Binary Codes

Computers use binary rather than decimal and have fixed precision for numbers. A binary number consists of only 0s and 1s represented in bits. Common binary operations include addition, subtraction, multiplication and division. Error detection methods like parity bits and Hamming codes add redundancy to detect and correct bit errors during data transmission.

Uploaded by

Primel Diago
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Binary Codes

Computers use binary rather than decimal and have fixed precision for numbers. A binary number consists of only 0s and 1s represented in bits. Common binary operations include addition, subtraction, multiplication and division. Error detection methods like parity bits and Hamming codes add redundancy to detect and correct bit errors during data transmission.

Uploaded by

Primel Diago
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

CODES

*The arithmetic used by computers differs in


some ways from that used by people.
*Computers perform operations on numbers
with finite and fixed precision.
*Computers use the binary rather than the
decimal system for representing numbers.
*On most computers, the amount of memory
available for storing a number is fixed at the
time the computer is designed.

Binary Numbers
*A binary number is a number that includes only ones
and zeroes.
*The number could be of any length or bit string.
*The following are all examples of binary numbers
101012
01010102
10111101012
01101011102
*Another name for binary is base-2 (pronounced "base
two")

What is a binary
number?
3
Binary Code
*Imagine a specie that only has two fingers. how
can they count?
* A computer is such kind of two-finger specie.
0 and 1
*Each digit of a binary number is called a bit.
*A binary number with eight bits (i.e. digits) is
called a byte.
*Bridging the Digital
Divide
1 6 23
16 6 3
63 21
935 2 3
935 72
Decimal-to-Binary
534 7275 935 935 1 534 Conversion
2 3 4 14 1 37 13
275
34 2910 = 111012
5 7 1452

01 1 00
1001 11
0 01 0 1 0010 01100
01
0
0 110 01
1 1 01
1
0 110 1 01
1 001 10
0 1 1
001
011
0 0100 010 1
0 110
0 110
001
01
01
Binary-to-Decimal 11 0110
01 101 1101 0010 0
110010 0
11
Conversion 1 1
111012 = 2910 0 1 010111101 00101011
1 001
0 1 0 1 0 01
1 0 01 11011
0
1 011 0 001011
5 00
1 0100
Conversion of Binary to
Decimal numbers
110112 = 1(24 ) + 1(23 ) + 0(22 ) + 1(21 ) + 1(20 )
= 1(16) + 1(8)+ 0(4)+ 1(2) + 1(1)
= 16 + 8+ 0+ 2 + 1
= 2710

11011.012 = 1(24 )+1(23)+0(22)+1(21)+1(20)+0(2-1)+1(2-2)


= 1(16)+1(8)+0(4)+ 1(2)+1(1) +0(0.5) + 1(0.25)
= 16 + 8+ 0+ 2 + 1 + 0 + 0.25
= 27.2510
Conversion of Decimal to
Binary number
Write the decimal 2910 to binary
Division by 2 Quotient Remainder
2 I 29 14 1
2 I 14 7 0
2I 7 3 1
2I 3 1 1
2I 1 0 1

2910 = 111012
Conversion of Decimal to Binary
number
Write the decimal 29.2510 to binary
Division by 2 Quotient Remainder
2 I 29 14 1
2 I 14 7 0
2I 7 3 1
2I 3 1 1
2I 1 0 1

Product Integer part


0.25 x 2 0.5 0
0.5 x 2 1.0 1

29.2510 = 11101.012
OPERATIONS
OF
BINARY
NUMBER
Addition (binary)
0 + 0 = 0 ; 1 + 0 = 1 ; and 1 + 1 = 10

1 11 1
011 01
 01011
11000
Subtraction (binary)
0 - 0 = 0 ; 1 - 0 = 1 ; 0 - 1 = 1 (need to borrow 1) ;
and 1 -1 = 0
0 10
111 0
 1001
101
Multiplication (binary)
0 * 0 = 0 ; 1 * 0 = 0 ; and 1 * 1 = 1

1 0 01
 1110
0000
1001
1001
1001
1111110
Division (binary)

111
11 10101
011
100
11
11
11
0
Error and Error
Correction
Error – case of mismatched data.
Bit Error – in a data sequence, if 1 is changed
to 0 or 0 is changed to 1.
Single Bit Error – the change in one bit in
the whole data sequence.
Multiple Bit data error – if there is a
change in two or more bits of data sequence of
transmitter to receiver.
Burst Error – the change of set of bits in
data sequence.
Parity bit – means nothing but an additional bit added
to the data at the transmitter before transmitting the
data.
Even Parity
Parity Bit Parity Bit
1000001 - 0 10001111 - 1
110000011 – 0 11100000 - 1

Odd Parity

Parity Bit Parity Bit


10001111 - 0 1000001 - 1
1110000 - 0 1100000 - 1
Hamming code - used to detect and correct the error
when data is moved.
Redundancy bit – the difference between the number
of bits of the actual data sequence and the transmitted
bits.
Number of parity bits: ≥ n + P + 1

Parity and Data bits position:


D7 , D6 , D5 , P4 , D3 , P2 , P1
Where P1, P3 and P4 are parity bits, D2,D6 and D7 are
data bits.
P 1 = D3 D 5 D 7
P 2 = D3 D 6 D 7
P 4 = D5 D 6 D 7
Example: Encode the data 1011 in even parity by using
Hamming code.

1 0 1 1
D7 D6 D5 P4 D3 P2 P1

P1 = 1 1 1 = 1
P2 = 1 0 1 = 0
P4 = 1 0 1 = 0
Codeword: 1010101
THE END

You might also like