number representation. representing numbers n numbers are represented as successive powers of a...

29
Number Representation

Upload: michael-oneal

Post on 02-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Number Representation

Representing numbers

Numbers are represented as successive powers of a base, or radix

Representing numbers

Numbers are represented as successive powers of a base, or radix

The powers increment upwards to the left, starting with zero to the far right

Representing numbers

Numbers are represented as successive powers of a base, or radix

The powers increment upwards to the left, starting with zero to the far right

For any base, b:

b0b1b2b3etc. . . .

Representing numbers

We typically use a base of 10 (presumably because we have ten fingers), the decimal system

100101102103etc. . . .

ones column

tens column

hundreds

column

thousands

column

Representing numbers

For any base b, there are b digits

Representing numbers

For any base b, there are b digits In base 10, there are 10 digits – 0 through 9

Representing numbers

For any base b, there are b digits In base 10, there are 10 digits – 0 through 9

100101ones column

tens column

When we want to represent a value greater than the highest digit, we have to make a change in the appropriate column to the left

1234567891 70892 0

etc. . . .

Representing numbers

In any base b, if we have n digits, the range of values we may represent is

bn

If we have two digits in base 10, b=10 and n=2

With two digits, we can represent 10 , or 100, values – 0 through 99

2

Representing numbers in computers Computers may store and transmit numbers

in the form of circuits

Representing numbers in computers Computers may store and transmit numbers

in the form of circuits A circuit has two states: ON and OFF

Representing numbers in computers Computers may store and transmit numbers

in the form of circuits A circuit has two states: ON and OFF Computers are therefore able to represent

numbers in a system that has two digits

Representing numbers in computers Computers may store and transmit numbers

in the form of circuits A circuit has two states: ON and OFF Computers are therefore able to represent

numbers in a system that has two digits Base two, the binary system, fits this

description

Representing numbers in computers Computers may store and transmit numbers in

the form of circuits A circuit has two states: ON and OFF Computers are therefore able to represent

numbers in a system that has two digits Base two, the binary system, fits this description The binary number system has the digits 0 and 1

Binary numbers

Binary numbers have only two digits

Binary numbers

Binary numbers have only two digits But that distinction aside, the system of

representing numbers is exactly the same as in the decimal system:

20212223etc. . . .

ones column

twos column

fours column

eights column

24sixteen

s column

Binary numbers

With only two digits, a sequence of binary numbers changes columns more quickly than a series of decimal numbers:

Decimal Binary 0 01 12 103 114 1005 1016 1107 1118 1000

etc. . . .

Essential terminology

When a binary number is used by a computer, a single digit is called a bit (short for binary digit)

10110010

bit

Numbers (computer words) are often stored in sequences of eight bits, called a byte

byte

A sequence of four bits is called a nibble

nibble

Essential terminology

The bit that represents the lowest power is called the least significant bit

10110010

least significant bit

The bit that represents the highest power is called the most significant bit

most significant bit

Essential terminology

Larger numbers need to be represented with two or more bytes (16 bits form a two-byte word)

10110010

least significant byte

The byte that represents the lower powers of the number is called the least significant byte

most significant byte

10110010

The byte that represents the higher powers of the number is called the most significant byte

Bit resolution

A computer system is often referred to as an “n bit system,” meaning it represents numbers with n digits

Bit resolution

A computer system is often referred to as an “n bit system,” meaning it represents numbers with n digits

In a binary system, b=2, so this is a statement to describe the resolution of the system

Bit resolution

A computer system is often referred to as an “n bit system,” meaning it represents numbers with n digits

In a binary system, b=2, so this is a statement to describe the resolution of the system

An 8-bit system can represent 2 , or 256, values8

Bit resolution

A computer system is often referred to as an “n-bit system,” meaning it represents numbers with n digits

In a binary system, b=2, so this is a statement to describe the resolution of the system

An 8-bit system can represent 2 , or 256, values A 16-bit system can represent 2 , or 65,136 values

8

16

Hexadecimal notation

Base 16, the hexadecimal system, is often used in computer parlance

Hexadecimal notation

Base 16, the hexadecimal system, is often used in computer parlance Since our Arabic number system does not have digits to represent values

greater than 9, alphabetic characters are used:

Decimal Hexadecimal

0 01 12 23 34 45 56 67 78 89 910 A11 B12 C13 D14 E15 F

Hexadecimal notation

Hexadecimal notation is a convenience

Hexadecimal notation

Hexadecimal notation is a convenience A four-bit nibble can be expressed as one hexadecimal bit

Hexadecimal notation

Hexadecimal notation is a convenience A four-bit nibble can be expressed as one hexadecimal bit An eight-bit byte can be expressed as two hex bits

10100110

A 6

To convert to decimal, multiply the most significant nibble by 16, then add the least significant nibble:

(10 * 16) + 6= 166