Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Number Systems New

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 23

Assembly language

Number Systems
We

humans use decimal number system as the basis for our daily
computing activities. But how about Computers? Do they use
decimals too?
No. Computers use different number system, called binary.

Decimal
Binary

numbers use 10 symbols (0,1,2,39) called digits.

numbers use only two symbols (0, and 1) called bits.

third binary system, hexadecimal (hex for short) can be used


as a convenient shorthand representation of the binary
numbers inside a computer. It uses 16 symbols (0,1,2,3
9,A,B,C,D,E,F) called hex digits
(For this reason hexadecimal as well as binary numbers are important
in the computer field)

Positional number systems


Decimal,

binary and hexadecimal are all positional number systems.

In a positional number system, each position is associated with a different


weight.
Ex. In the Decimal number 25.4, the weights of the three positions, from right to
left, are 1/10, 1, and 10.
2

5 . 4

10 1

1/10 weights

The weight of each position determines how much the digit in that position
contributes to the value of the number.
For example, because the 2 in 25.4 occupies the 10s position ( i.e., the position
with weight 10), it contributes 2 x 10 = 20 to the value of the number. The value
of a decimal number is the sum of each digit times its weight. Thus the value of
25.4 is:
2 x 10 + 5 x 1 + 4 x 1/10

In

a decimal number, weights increase by a factor of 10 from


right to left from one position to the next. The weight of the
position to the immediate left of the decimal point is always 1.
because decimal numbers have 10 symbols (0 to 9), and have
weights that increase by a factor of 10, we call decimal a base
10 or radix 10 positional number system.

We

call the period in a number that divides the whole part


from the fractional part the radix point. When we are dealing
with decimal numbers, we usually call the radix point as
decimal point.

While in binary and hexadecimal numbers, we can similarly


call the radix point the binary point and hexadecimal point,
respectively.

Binary

is the base 2 positional number system. Thus, in


the binary number 1011.1, the weights of each position
increase by a factor of 2 from right to left. As in decimal,
the position to the intermediate left of the radix point
has weight 1. thus, in the binary number 1011.1, the
weights are
1 0 1 1 . 1
8 4 2 1 .

weights (in decimal)

and its value in decimal is


1x8 +0x4 +1x2

+1x1

+ 1 x = 11.5

Hexadecimal

is the base 16 positional number system. For


its symbols we use 0 to 9, and A to F. the weights in a
hexadecimal number increase by a factor of 16.

Ex. In the hexadecimal number 1CB.8, the weights are:


1

256 16

1/16 weights (in decimal)

And its value is:


1 x 256 + C x 16 + B x 1 + 8 x 1/16
Substituting the decimal equivalents for the symbols
1 x 256 + 11(C) x 16 + 12(B) x 1 + 8 x 1/16 = 459.5

Most significant & Least Significant


The

leftmost position in a positional number


system has the most weight, and we call the
symbol in that position as the most
significant.
On the other hand, the right most position has
the least weight, and we call it as the least
significant.

For

example in the binary number 1100


the 1 in the leftmost position is the
most significant bit (MSB) and the 0 in the
rightmost position is the least significant
bit (LSB).
note: in decimal and hexadecimal numbers, we use
the terms most significant digit (MSD) and least
significant digit (LSD)

Another

examples are:
The complement of 1 in binary;
( 2 1) 1 = 0 complement = 0
the complement of 3 in hexadecimal;
( 16 1) 3 = C complement = C

Computer

circuits are designed to operate on chunks of


data of a specific length. These chunks of data are called
words.

Common

word sizes for modern computers are 32 bits ( 4


bytes) and 64 bits (8 bytes)

The

term positive is used for a number greater than or


equal to zero. But in assembly numbers greater or equal
to zero are called non-negative numbers and those lesser
than zero are negative numbers.

When

specifying computer memory sizes we use the


prefixes kilo (K) , mega (M) and giga (G).

But

the use of this prefixes is contrary to their


usual meanings;
Prefixes
Kilo
Mega
Giga

Decimal
Equivalent
1,000 (thousand)

Actual Memory
sizes
1024

1,000,000
(millions)
1,000,000,000
(billions)

1,048,576
1,073,741,824

Arithmetic with Positional Numbers


The rules for performing arithmetic with positional
numbers are essentially the same for all bases.
Example:
a.

1 carry
28
+39
67

b.1 borrow
34
- 8
26

c.

211
3000
2
2998

borrow

Binary

- addition

111 carries
01100
+11110
101010

12
30
42

Binary

- subtraction

2 borrow
101
+ 011
010

5
3
2

Hexadecimal

- addition

1 carry
A9
+ 19
C2

169
25
194

Hexadecimal

- addition

16 borrow
A5
+ 2B
7A

165
43
122

Number Base Conversions


Dividing a number repeatedly by b yields
remainders equal to the symbols of that number
written as a base b number.
Example:

0
10 /
9
10 / 90
10 / 905

Answer: 905

9 remainders
0
5

Number Base Conversions


Binary
Example:

0
2
2
2
2

Answer: 1011

/
/
/
/

1
2
5
11

1 remainders
0
1
1

Number Base Conversions


Binary
Example:

0 1 remainders
16 / 1
14 = E
16 / 30
Answer: E1

Number Base Conversions (fractional)

To

convert a fraction to a different


base, we repeatedly multiply by the
target base, stripping off the whole
part of the product at each step.
We continue multiplying until a
fractional part equal to zero occurs.

Example:
.6875
x
1

2
.3750

x
0

2
.7500

x
1

2
.5000

x
1

start with this multiplication and work down

2
0000

answer:

0.1011

To convert

a number that has a whole part and a


fractional part, we simply do each part separately.
Example.
a. To convert 14.6875 decimal to binary we convert its
whole part 14 (to get 1110), we convert its fractional part
0.6875 (to get .1011) and we then put the two results
together (to get 1110.1011)

Multiple repetition
Example:
.1

start with this multiplication and work down

x 2
0

.2
x 2

.4

answer:

0.0 0011 0011 0011 0011 unending loop of (0,0,1,1)

No matter how many times we multiply, we will never get a zero fractional part

x 2
0

.8
x 2

.6
x 2

.2
x 2

.4

There is nothing wrong with this procedure. It simply tells us that 0.1 decimal is
equal to the infinite-length binary fraction.

You might also like