Sunteți pe pagina 1din 35

NUMBER SYSTEMS

Positional Number Systems

- Each digit position has an associated


weight
- The value of the number is a weighted
sum of the digits
- The digit in position I has weight ri ,
Where r is the radix (base)

Octal and Hexadecimal Numbers

- Radix 8 and 16
- Useful for representing multi-bit numbers
-Conversion from binary is done
by separating the bits into groups of

three or four (R-L) and replace each group


with the corresponding octal or hexadecimal
number

- If the number contains digits to the right of the


binary point, we group the part after the binary

point(L-R)
- To convert from Octal and Hexadecimal, we

replace each digit with the corresponding 3 or


4 bits string.
- Conversion from Decimal to Binary,Octal &
Hexadecimal is achieved by dividing by the
radix.

Fractions

Binary to decimal
10.1011 =>
1
1
0
1
0
1

x
x
x
x
x
x

2-4
2-3
2-2
2-1
20
21

=
=
=
=
=
=

0.0625
0.125
0.0
0.5
0.0
2.0
2.6875

Fractions

Fractions
(0.375)10
0.375 X 2 = 0.750 0
0.750 X 2 = 1.500 1
0.500 X 2 = 1.000 1
000 X 0 = 0
0
(0.375)10= (0.011)2

Octal Addition (&


Subtraction)
11
456
123
601

Subtraction

Hexadecimal Addition (&


Subtraction)

Subtraction
3145
-1976

Representation of negative numbers


- Singed-magnitude system: the number consists
of magnitude and symbol. The MSB is for the sign
0 means positive &1 means negative
- There are two representation for 0, 1000 (-0) &
0000 (+0).
- For n-bit integer the range is (2n-1 1) to +(2n-1-1)
+18 = 00010010
-18 = 10010010

- One complement : The MSB is for the sign.

- Boolean complement all bits to negate


+18 = 00010010
-18 = 11101101
- Two representations of zero: 0000 (+0)
1111 (-0)

- The range is (2n-1 1) to +(2n-1-1).

- Twos complement: MSB is for the sign.


- The range is (2n-1) to (2n-1-1).
-

3 = 00000011
Boolean complement gives 11111100
Add 1 to LSB
+1
11111101

- Only one representation for 0.


0 = 00000000
Bitwise not
11111111
Add 1 to LSB
+1
Result
1 00000000
Overflow is ignored, so:
-0=0

- Twos

Complement Addition

Overflow: An addition overflows if the


signs of the addends are the same and the
sign of the sum is different from
the addends sign.

1001
+ 0101
1110 = -2
(a) (-7) + (+5)

1100
+ 0100
10000 = 0
(b) (-4) + (+4)

0011
+ 0100
0111 = 7
(c) (+3) + (+4)

1100
+ 1111
11011 = -5
(d) (-4) + (-1)

0101
+ 0100
1001 = Overflow
(e) (+5) + (+4)

1001
+ 1010
0011 = Overflow
(f) (-7) + (-6)

Subtraction rules:

Perform a bit-by-bit complement of the


subtrahend and add the complemented
subtrahend to the minuend with an initial
carry in of 1 instead of 0.

0010
+ 1001
1011 = -5
(a) M = 2 = 0010
S = 7 = 0111
-S = 1001

0101
+ 1110
10011 = 3
(b) M = 5 = 0101
S = 2 = 0010
-S = 1110

1011
+ 1110
11001 = -7

(c) M = -5 = 1011
S = 2 = 0010
-S = 1110

0101
+ 0010
0111 = 7

(d) M = 5 = 0101
S = -2 = 1110
-S = 0010

0111
+ 0111
1110 = Overflow
(e) M = 7 = 0111
S = -7 = 1001
-S = 0111

1010
+ 1100
10110 = Overflow
(f) M = -6 = 1010
S = 4 = 0100
-S = 1100

The Byte, Nibble, and Word


1 byte = 8 bits
1 nibble = 4 bits
1 word = size depends on data pathway
size.
Word size in a simple system may be one
byte (8 bits)
Word size in a PC is eight bytes (64 bits)

-Codes are group of special symbols used to


represent numbers, letters or words.
1- Binary codes for decimal numbers (BCD)
- Binary Coded Decimal (BCD) is another way
to present decimal numbers in binary form.
- BCD is widely used and combines features of
both decimal and binary systems.

- Each digit of a decimal is represented by its


four-bit binary equivalent (1 to 9)
- To represent the decimal number 10 we need
eight bits (0001 0000)

To convert the number 87410 to BCD

Each digit always uses four bits.


The BCD value can never be greater than 9
Reverse the process to convert BCD to decimal.

BCD is not a number system.

BCD is a decimal number with each digit


encoded to its binary equivalent.
A BCD number is not the same as a straight
binary number.
The primary advantage of BCD is the relative
ease of converting to and from decimal.

Decimal Binary Octal Hexadecimal


BCD
0
0
0
0
0
1
1
1
1
0001
2
10
2
2
0010
3
11
3
3
0011
4
100
4
4
0100
5
101
5
5
0101
6
110
6
6
0110
7
111
7
7
0111
8
1000
10
8
1000
9
1001
11
9
1001
10
1010
12
A
0001 0000
11
1011
13
B
0001 0001
12
1100
14
C
0001 0010
13
1101
15
D
0001 0011
14
1110
16
E
0001 0100
15
1111
17
F
0001 0101

2- American Standard Code for Information


Interchange (ASCII)
- It is a seven bit code. It has 27 possible code
groups.
- Represents characters and functions found on
a computer keyboard.
- Examples of use are: to transfer information
between computers, between computers and
printers, and for internal storage.

3- Gray code
Two successive values differ in only one bit

4- Codes for detecting and correcting


errors

Error means corruption of data.


- Parity Bit
- Hamming Code

Parity bit:
It is an extra bit that is attached to
a code group that is being transferred from one
location to another. It is made either 0
or 1. Depending on the number of 1s that
are contained in the code group.
Even parity:
The value of the parity bit is chosen so that
the total number of 1s, including the parity
bit, is an even number;
1 1000011

Odd parity:
The value of the parity bit is chosen
so that the total number of 1s, including the
parity bit, is an odd number;
1 1000001

S-ar putea să vă placă și