Number Systems

14
Computing Theory – F453 Number Systems

description

Number Systems. Computing Theory – F453. Data Representation. Data in a computer needs to be represented in a format the computer understands. This does not necessarily mean that this format is easy for us to understand. Not easy, but not impossible! - PowerPoint PPT Presentation

Transcript of Number Systems

Page 1: Number Systems

Computing Theory – F453

Number Systems

Page 2: Number Systems

Data in a computer needs to be represented in a format the computer understands.This does not necessarily mean that this format is easy for us to understand.

Not easy, but not impossible!

A computer only understand the concept of ON and OFF.Why?

How do we translate this into something WE understand?We use a numeric representation (1s and 0s)

Data Representation

Page 3: Number Systems

If a computer can only understand ON and OFF, which is represented by 1 and 0, then which is which?

1 = ON0 = OFFThis is known as the Binary system. Because there are only 2 digits involved, it is known as Base 2.

But what does it MEAN??!

Data Representation

Page 4: Number Systems

We use the Denary Number System.This is in Base 10, because there are 10 single digits in our number system.

Why? We are surrounded by things that are divisible by ten.

Counting in tens is not a new phenomenon…Even the Egyptians did it!

Denary Numbers

Page 5: Number Systems

In the real world we have to work with decimal numbers, but there is no place in binary for a decimal point. In these cases, we need to ‘normalise’ the number.

In short, we place everything to the right of the decimal point:

Real Numbers

10111.00.10111 x 25

0.10111 x 2101

010111101

Positive exponent represents the decimal

point moving left

ExponentMantissa

Page 6: Number Systems

Example two: The binary number 10.11011 with 8 bits for the mantissa and 6 for the exponent

Real Numbers

.10110110. .1011011 x 22 0.10111 x 210

01011011000010

Positive exponent represents the decimal

point moving left

ExponentMantissa32 16 8 4 2 1

0 0 0 0 1 0

Page 7: Number Systems

Example two: The denary number 37.5 with 8 bits for the mantissa and 6 for the exponent

Real Numbers

37.5 =

100101.10.1001011 x 26

0.1001011 x 2110

01001011000110

Positive exponent represents the decimal

point moving left

ExponentMantissa

32 16 8 4 2 1 .5 .25 .125

.0625

.03125

1 0 0 1 0 1 1 0 0 0 0

Page 8: Number Systems

Example three: The denary number 52.75 with 8 bits for the mantissa and 8 for the exponent

Real Numbers – Your Turn

52.75 =

110100.110.11010011 x 26

0.11010011 x 2110

01101001100000110

Positive exponent represents the decimal

point moving left

ExponentMantissa

32 16 8 4 2 1 .5 .25 .125

.0625

.03125

1 1 0 1 0 0 1 1 0 0 0

Page 9: Number Systems

Example four: The denary number 22.8125 with 10 bits for the mantissa and 5 for the exponent

Real Numbers – Your Turn

22.8125 =

010110.11010.101101101 x 25

0.101101101 x 2101

010110110101101

Positive exponent represents the decimal

point moving left

ExponentMantissa

32 16 8 4 2 1 .5 .25 .125

.0625

.03125

0 1 0 1 1 0 1 1 0 1 0

Page 10: Number Systems

Example: The binary number 01011100000011 with 8 bits for the mantissa and 6 for the exponent

Real Numbers – In reverse

01011100000011

0.1011100 x 211

0.1011100 x 23

0101.1100

ExponentMantissa

32 16 8 4 2 1 .5 .25

.125

.0625

.03125

0 0 0 1 0 1 1 1 0 0 0 = 5.75

Page 11: Number Systems

In the real world we also have to work with numbers which are less than 1, or decimals.This is tackled in the same way, but we make use of two’s complement for the exponent:

Real Small Numbers

0.000101010.10101 x 2-3

0.10101 x 2-11

0.10101 x 2-11

01010111110101

Negative exponent represents the decimal

point moving right

ExponentMantissa

128

64

32 16 8 4 2 1

0 0 0 0 1 0 1 1128

64

32 16 8 4 2 1

1 1 1 1 0 1 0 1

Page 12: Number Systems

Example five: The binary number 0.00110 with 8 bits for the mantissa and 8 for the exponent

Real Numbers – Your Turn

0.001100.110 x 2-2

0.110 x 2-10

0.110 x 211111110

0000011011111110

ExponentMantissa

128

64

32 16 8 4 2 1

0 0 0 0 0 0 1 0128

64

32 16 8 4 2 1

1 1 1 1 1 1 1 0

Page 13: Number Systems

Example: The binary number 01011110111010 with 8 bits for the mantissa and 6 for the exponent

Real Numbers – In reverse

01011110111010

0.1011110 x 2-110

0.1011110 x 2-6

0.0000001011110

ExponentMantissa

128

64

32 16 8 4 2 1

0 0 0 0 0 1 1 0

128

64

32 16 8 4 2 1

1 1 1 1 1 0 1 0

Page 14: Number Systems

In the examples, the point in the mantissa is always placed before the first zero (eg. 0.11010).

This not only allows for the maximum number to be held, but by ensuring that the first two digits are different, the mantissa is said to be normalised.

Therefore, for a positive number, the first digit is always a zero, and the exponent is held in two’s complement form.

Normalisation