1 lecture 2 number systems introduction to information technology dr. ken tsang 曾镜涛 email:...

Post on 23-Dec-2015

216 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

Lecture 2Number Systems

Introduction to Information Technology

Dr. Ken Tsang 曾镜涛Email: kentsang@uic.edu.hkhttp://www.uic.edu.hk/~kentsang/IT/IT3.htmRoom E408 R9

3

Outline Decimal Number System Binary Number System Hexadecimal Number System Positional Numbering System Conversions Between Number Systems Conversions Between Power-of-Two

Radices Bits, Bytes, and Words Basic Arithmetic Operations with Binary

Numbers

4

Natural Numbers Natural numbers

Zero and any number obtained by repeatedly adding one to it

Negative Numbers A value less than 0, with a – sign

Integers A natural number, a negative number, zero

Rational Numbers An integer or the quotient of two integers

We will only discuss the binary representation of non-negative integers

5

Decimal Number System A human usually has four fingers and a thumb

on each hand, giving a total of ten digits over both hands

10 digits: 0,1,2,3,4,5,6,7,8,9

Also called base-10 number system, Or Hindu-Arabic, or Arabic system

Counting in base-10 1,2,…,9,10,11,…,19,20,21,…,99,100,…

Decimal number in expanded notation 234 = 2 * 100 + 3 * 10 + 4 * 1

6

Binary Number System Binary number system has only two digits

0, 1 Also called base-2 system

Counting in binary system 0, 1, 10, 11, 100, 101, 110, 111, 1000,….

Binary number in expanded notation (1011)2 = 1*23 + 0*22 + 1*21 + 1*20

(1011)2 = 1*8 + 0*4 + 1*2 + 1*1 = (11)10

7

Gottfried Leibniz (1646-1716)

Leibniz, the last universal genius, invented at least two things that are essential for the modern world: calculus, and the binary system.

He invented the binary system around 1679, and published in 1701. This became the basis of virtually all modern computers.

8

Leibniz's Step Reckoner

Leibniz designed a machine to carry out multiplication, the 'Stepped Reckoner'. It can multiple number of up to 5 and 12 digits to give a 16 digit operand. The machine was later lost in an attic until 1879.

9

An ancient Chinese binary number system in Yi-Jing (易经)

Two symbols to represent 2 digits Zero: represented by a broken line One: represented by an unbroken line “—” yan 阳爻,“ --” yin 阴爻。

10

Hexadecimal Hexadecimal number system has 16 digits

• 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F• Also called base-16 system

Counting in Hexadecimal 0,1,…,F,10,11,…,1F,20,…FF,100,…

Hexadecimal number in expanded notation (FF)16 = 15*161 + 15*160 = (255)10

11

Some Numbers to Remember

12

Positional Numbering System The value of a digit in a number

depends on: The digit itself The position of the digit within the

number So 123 is different from 321

123: 1 hundred, 2 tens, and 3 units 321: 3 hundred, 2 tens, and 1 units

13

Base rr Number System rr symbols Value is based on the sum of a

power series in powers of rr

rr is called the base, or radix

14

The Octal System (base 8) Valid symbols: 0,1,2,3,4,5,6,7

Questions: 2. How to count in

Octal?

1. 268 = ?

15

Why Binary? A computer is a Binary machine It knows only ones and zeroes Easy to implement in electronic

circuitsReliableCheap

16

Bit and Byte BIT = Binary digIT, “0” or “1” State of on or off ( high or low) of a

computer circuit Kilo 1K = 210 = 1024 ≈ 103 Mega 1M = 220 = 1,048,576 ≈ 106 Giga 1G = 230 = 1,073,741,824 ≈ 109

17

Bit and Byte Byte is the basic unit of addressable

memory 1 Byte = 8 Bits The right-most bit is called the LSB

Least Significant Bit The Left-most bit is called the MSB

Most Significant Bit

18

Why Hexadecimal? Hexadecimal is meaningful to humans,

and easy to work with for a computer Compact

A BYTE is composed of 8 bits One byte can thus be expressed by 2

digits in hexadecimal 11101111 EF 11101111b EFh

Simple to convert them to binary

19

Binary to Decimal

Conversions Between Number Systems

20

Conversions Between Number Systems Hexadecimal to Decimal

21

Conversions Between Number Systems

Octal to Decimal

(32)8 = (?)10

What’s wrong?

(187)8 = 1*64 + 8*8 + 7*1

22

Conversions Between Number Systems Decimal to Binary

Reading the remainders from bottom to top, we have 32110 = 1010000012

remainderquotient

321 / 2 = 160 1 160 / 2 = 80 0 80 / 2 = 40 0 40 / 2 = 20 0 20 / 2 = 10 0 10 / 2 = 5 0 5 / 2 = 2 1 2 / 2 = 1 0 1 / 2 = 0 1

32110 = ?2

23

One More ExampleConvert 14710 to binary

So, 14710 = 100100112

24

Conversions Between Number Systems

Decimal to Base rr Same as Decimal to Binary Divide the number by rr Record the quotient and remainder Divide the new quotient by rr again ….. Repeat until the newest quotient is 0 Read the remainder from bottom to top

25

Exercises

Convert 19910 to binary Convert 25510 to binary Convert 25510 to hexadecimal Convert 2558 to decimal Convert 12316 to decimal

Please show your steps of conversion clearlyPlease show your steps of conversion clearly..

26

Conversions Between Power-of-2 Radices

Because 16 = 24, a group of 4 bits is easily recognized as a Hexadecimal digit

And a group of 3 bits is easily recognized as one Octal digit

To convert a Hex or Octal number to a binary numberRepresent each Hex or Octal digit with 4 or 3 bits in

binary

27

Convert a binary number to Hex or Oct number

Conversions Between Power-of-2 Radices

28

Basic Arithmetic Operations with Binary Numbers

Rules for Binary Addition 1+1=0, with one to carry to the

next place

29

Example

30

Example

31

Basic Arithmetic Operations with

Binary Numbers

Rules for Binary Subtraction 1 - 0 = 1 1 - 1 = 0 0 - 0 = 0 0 - 1 = 1 … borrow 1 from the

next most significant bit

32

Example

minuend

subtrahend

difference

33

Two’s Complement Alternative way of doing Binary Subtraction Invert the digits (of the subtrahend)

0001 0001 1110 1110 Add 1

1110 1110 1110 1111 Add this to the minuend

1110 1111 + 0010 0101 = 1 0001 0100 Drop/Ignore the MSB

0001 0100

34

Why “Two’s Complement” works?

Suppose A = 1001001 a 7-bit binary minuend B = 0011011 a 7-bit binary subtrahend Want to calculate the difference C = A – B Rewrite C = A + (1111111 – B ) +1 –

1000000 D = 1111111 – B = 1100100 same as

converting 0 to 1 and 1 to 0 in B (taking 2’s complement of each bit in B)

So C = A + D + 1 - 1000000

35

A “ten’s complement” scheme for decimal subtraction

A = 1234 a 4-digit decimal minuend B = 0567 a 4-digit decimal subtrahend Want to calculate the difference C = A –

B Rewrite C = A + (9999 – B ) +1 – 10000 D = 9999 – B = 9432 (taking 10’s

complement of each digit in B) So C = A + D + 1 - 10000

36

Binary Multiplication

37

Exercises00011010 + 00001100 = ?

00110011 - 00010110 = ?

00101001 × 00000110 =?

38

Summary Decimal, Binary, and Hexadecimal

Systems Positional Numbering Systems Conversions Between Number Systems Conversions Between Power-of-Two

Radices Bits and Bytes Basic Arithmetic Operations with Binary

Numbers

3939

Resolution: Scanner and digital cameraResolution: Scanner and digital camera

Scanner and digital camera manufacturers Scanner and digital camera manufacturers often refer to two different types of resolution often refer to two different types of resolution when listing product specs: optical resolution when listing product specs: optical resolution and interpolated (or digital) resolution. The and interpolated (or digital) resolution. The optical resolution is the true measurement of optical resolution is the true measurement of resolution that the output device can capture. resolution that the output device can capture. Interpolated, or digital, resolution is acquired Interpolated, or digital, resolution is acquired artificially. artificially.

SPI (samples per inch) refers to scanning SPI (samples per inch) refers to scanning resolution.resolution.

4040

Summary-Summary- In this lecture, we have discussed: In this lecture, we have discussed:

Digitizing imagesDigitizing images Pixels & resolutionPixels & resolution Some common graphic file formatsSome common graphic file formats Digital cameras & how to purchase oneDigital cameras & how to purchase one Dynamic range, white balance, and color Dynamic range, white balance, and color

temperaturetemperature Graphic softwaresGraphic softwares

4141

High dynamic range imaging (HDRI) High dynamic range imaging (HDRI)

The intention of HDRI is to accurately represent the The intention of HDRI is to accurately represent the wide range of intensity levels found in real scenes wide range of intensity levels found in real scenes ranging from direct sunlight to the deepest shadows. ranging from direct sunlight to the deepest shadows.

HDR images require a higher number of bits per color HDR images require a higher number of bits per color channel than traditional images, both because of the channel than traditional images, both because of the linear encoding and because they need to represent linear encoding and because they need to represent values from 10−4 to 108 (the range of visible values from 10−4 to 108 (the range of visible luminance values) or more. 16-bit ("half precision") or luminance values) or more. 16-bit ("half precision") or 32-bit floating point numbers are often used to 32-bit floating point numbers are often used to represent HDR pixels. represent HDR pixels.

http://en.wikipedia.org/wiki/http://en.wikipedia.org/wiki/High_dynamic_range_imagingHigh_dynamic_range_imaging

top related