22

Binary+Number+System+(Lesson+2)

Embed Size (px)

DESCRIPTION

dig 1

Citation preview

Page 1: Binary+Number+System+(Lesson+2)
Page 2: Binary+Number+System+(Lesson+2)
Page 3: Binary+Number+System+(Lesson+2)

The Way Computers Count

Page 4: Binary+Number+System+(Lesson+2)

Information (Data) and RepresentationInformation (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 aren’t the only ones…. There are many languages…. Isn’t an idea in Spanish just as valid as an idea in

English? Number systems are just another way of

expressing information.

Page 5: Binary+Number+System+(Lesson+2)

Number Systems in GeneralNumber Systems in General Decimal (base 10)

• What “us humans” are experienced in using• Based on powers of 10 (“we’ve 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.

Page 6: Binary+Number+System+(Lesson+2)

Number Systems in General IINumber 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. We’ll see later, for example, how arithmetic

can be done in binary.

Page 7: Binary+Number+System+(Lesson+2)

Decimal and Binary ComparisonDecimal and Binary ComparisonDecimal:Decimal:

101010

1 x 103=10000 x 102=0

1 x 10=100 x 1=0

Binary:Binary:

1010 2

1 x 23=80 x 22=0

1 x 2=20 x 1=0

Notice: 8+0+2+0 = 10 (decimal)Notice: 1000+00+10+0 = 1010

Notice that the first column is the “1’s” column for any number system!

Page 8: Binary+Number+System+(Lesson+2)

1 0 1 0 0 1 0 12

Most Significant Bit (MSB) Least Significant Bit (LSB)

Page 9: Binary+Number+System+(Lesson+2)

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 it’s position.

Second: Each power of 2 number is represented by one unique bit.

Page 10: Binary+Number+System+(Lesson+2)

1 0 1 0 0 1 1 02

128 + 0 + 32 + 0 + 0 + 4 + 2 + 0 = 16610

Thus, 101001102 equals 16610

20212223242527 26

Page 11: Binary+Number+System+(Lesson+2)

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 “0’s” everywhere else.

So: 1610 = 100002

Page 12: Binary+Number+System+(Lesson+2)

Next, the “hard but guaranteed” way:

Take the number, example: 1410

Divide by 2: 2

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

Save the result and remainder: = 0 remainder: 1

Take the remainders in reverse order:

Thus 1410 = 11102

Page 13: Binary+Number+System+(Lesson+2)

Take the number, example: 2310

Divide by 2: 2

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

Save the result and remainder: = 1 remainder: 0

Thus 2310 = 101112

Take the remainders in reverse order:

Page 14: Binary+Number+System+(Lesson+2)

Here's an illustration of converting 141 to binary:

Page 15: Binary+Number+System+(Lesson+2)

• 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

Page 16: Binary+Number+System+(Lesson+2)

We might want to know what number of bits are needed to represent a given decimal number. Let’s 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 can’t 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 it’s less than 25610 .

Note: 20010 = 110010002 which is 8 bits….

Page 17: Binary+Number+System+(Lesson+2)

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

Page 18: Binary+Number+System+(Lesson+2)

9 times bigger! 36 times bigger!

Page 19: Binary+Number+System+(Lesson+2)

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

Page 20: Binary+Number+System+(Lesson+2)
Page 21: Binary+Number+System+(Lesson+2)

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.

Page 22: Binary+Number+System+(Lesson+2)