Anda di halaman 1dari 22

The Way Computers

Count

Information (Data) and


Representation
Any idea or thought must be represented

so that it can be saved, processed and


conveyed.

We humans are experienced in using speech and

writing.
Writing needs some form of language.

We arent the only ones.


There are many languages.
Isnt an idea in Spanish just as valid as an idea in
English?

Number systems are just another way of

expressing information.

Number Systems in
General
Decimal (base 10)
What us humans are experienced in using
Based on powers of 10 (weve got 10 fingers)

Binary (base 2)
What the computers need
Based on powers of 2
The computer has 2 fingers; on and off
This is called a bit for a binary digit

Hexadecimal (base 16)


Something to make life easier

Octal (Base 8)
Another variation of making life easier
Not used much anymore

Variations on a theme
BCD, ASCII, etc.

Number Systems in General


II
All Number Systems are equally valid.

None are more right than any other.


We use decimal because we have 10 fingers.

Any number that can be represented in

one system can be converted into any


other.
Any function that can be done in one
system can also be done in another.
Well see later, for example, how arithmetic

can be done in binary.

Decimal and Binary


Comparison
Decimal:
1 x 103=1000
0 x 102=0
1 x 10=10
0 x 1=0

101010

Notice: 1000+00+10+0 = 1010

Binary:
1 x 23=8
0 x 22=0
1 x 2=2
0 x 1=0

1010 2

Notice: 8+0+2+0 = 10 (decimal)

Notice that the first column is the 1s column


for any number system!

1 0 1 0 0 1 0 12

Most Significant Bit (MSB)

Least Significant Bit (LSB)

00002 =010
00012 =110
00102 =210
00112 =310
01002 =410
01012 =510
01102 =610
01112 =710
10002 =810

We can note a
couple of
interesting things:
First: Each bit
alternates equally
between 1 and 0
based upon its
position.
Second: Each
power of 2 number
is represented by
one unique bit.

1 0 1 0 0 1 1 02
27 26 25 24 23 22 21 20
128 + 0 + 32 + 0 + 0 + 4 + 2 + 0

Thus, 101001102 equals 16610

= 16610

A bit more involved


(No Pun Intended.)
First the Easy Way:
If the decimal number is a perfect power of 2 (i.e. 2, 4,
8, etc.) we can just put a 1 in the appropriate column,
and put 0 everywhere else.
Example: 1610 is 24,
We put 1 in the 5th column:

100002 and 0s everywhere else.

So: 1610 = 100002

Next, the hard but guaranteed way:


Take the number, example:
Divide by 2:

1410
2

Save the result and remainder: = 7


Divide by 2 again:
2
Save the result and remainder: = 3
Divide by 2 again:
2
Save the result and remainder: = 1
Divide by 2 again:
2

remainder: 0

Save the result and remainder: = 0

remainder: 1

Take the remainders in reverse order:


Thus 1410 = 11102

remainder: 1
remainder: 1

Take the number, example:


Divide by 2:

2310
2

Save the result and remainder: =11


Divide by 2 again:
2
Save the result and remainder: = 5
Divide by 2 again:
2
Save the result and remainder: = 2
Divide by 2 again:
2

remainder: 1

Save the result and remainder: = 1

remainder: 0

Take the remainders in reverse order:


Thus 2310 = 101112

remainder: 1
remainder: 1

Here's an illustration
of converting 141 to
binary:

Binary normally operates (unlike Decimal) with a

fixed number of bits


Typically, this number of bits is a power of 2 itself (8
bits, 32 bits, etc.)
We might want to know how wide a range of numbers
we can handle with a number of bits.
An easy way is to say that if we have n bits, we can
cover the range of integers from 0 to 2n-1
Example: 8 bits can represent 0 to 28-1 or 0 to 255
Remember: 0 to 2n-1

We might want to know what number of bits are needed to

represent a given decimal number.


Lets start with the idea we used last time: 2n-1
Take the decimal number X, and find the smallest power of
two that is equal or greater than X.
We then need n bits, from our 2n
In most cases, we will actually be able to represent a
number larger than X with n bits, but this cant be helped.
Example: Represent 20010 in binary.
We figure out that the smallest power of 2 greater than
20010 is 25610 which requires 9 bits.
Thus 20010 requires 8 bits because its less than 25610 .
Note: 20010 = 110010002 which is 8 bits.

Binary normally operates (unlike Decimal) with a fixed

number of bits
The first CPU (the 4004) used 4 bits.
The next major group of CPUs (the 8000, 8008, 6800,
etc.) used 8 bits.
The next major group of CPUs (the 8086, 80186, 68000,
etc.) used 16 bits.
The current generation of CPUs (the Pentiums, the
68020, etc.) use either 32 bits or 32/64 bits.
The most powerful CPUs (the Intel Itanium and AMD
64) use a full 64 bits.
Some large computers use 128 or 256 bits.

9 times bigger!

36 times bigger!

This file would be 16 times smaller than (a).


but, which would you like your doctor using?
A digitized chest radiograph displayed with image resolutions of:
(a)256x256x8 bits
(b) 32x32x8 bits
(c) 256x256x2 bits

Below is a short list of some commonly used digital coding algorithms


PCM - PCM was invented by A.H. Reeves in 1939. Using only two alternative
pulse values (0 and 1), a 16- pulse train is generated which indicates the sampled
value (for example, 1010 1111 0110 1101, a binary coded 16 bit number). During
conversion, 16 bit amplitudes A1, A2, A3 ... are generated with a rate 44,100/sec.
The demand on the storage device and speed of transmission channel is 88,200
Bytes/sec. This is a 'brute force' approach, which is not the most effective way of
using the storage device and transmission channel.
DPCM - Differential Pulse Code Modulation. During conversion only 4 bit (for
example) differences between consecutive amplitudes are generated (A2-A1),
(A3-A2), (A4-A3) ... at the rate of 44,100 /sec. Demand on the storage device and
speed of transmission channel is 22,050 Bytes/sec.
ADPCM - Adaptive Differential Pulse Code Modulation. Depending on the
signal, the number of available bits to represent the difference between
consecutive 16 bit samples is varied. For example, for the case of total quiet at
the input (or small signal) the difference could be switched off totally or
represented only by 1 bit. This is probably the most effective way of coding.
Similar means of coding could be used for video signals because there is not
much change from frame to frame most of the time.

Anda mungkin juga menyukai