1. discrete / continuous representations of numbers – binary & decimal bits hexadecimal -...

50
1

Post on 15-Jan-2016

239 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

1

Page 2: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

Discrete / ContinuousRepresentations

Of numbers – binary & decimalBitsHexadecimal - 'Hex'Representing text

Bits and Bytes

Page 3: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

3

By the end of this lecture you should …Have an awareness of

– What digits, bits and bytes are– What 'digitizing' is– What 'hex' is, why it is used and how to use it– What ASCII and Unicode are

Understand better how computers represent information

Page 4: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

Discrete / ContinuousRepresentations

Of numbers – binary & decimalBitsHexadecimal - 'Hex'Representing text

Bits and Bytes

Page 5: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

5

Discrete vs Continuous

Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Page 6: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

6

Discrete vs Continuous

Some things have a continuous range of values. Light and color for example have varying hues or range of intensities.

Clicking and drumming are discrete. Humming and whistling are continuous.

Page 7: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

Analogue Digital

7

FreeFoto.com

Page 8: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

8

Analogue and digital

Digital storage is discrete Analogue storage is continuous Digital processing is carried out through

discrete specified steps Analogue processing is uses the physical

properties of objects and processes to model

Page 9: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

Discrete / ContinuousRepresentations

Of numbers – binary & decimal

BitsHexadecimal - 'Hex'Representing text

Bits and Bytes

Page 10: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

10

Numbers

What is a number Numbers are things that we count with Numbers have an order We add numbers together to get other numbers.

Something that we use numerals to represent numbers

(Numerals - 'arabic' 'roman' 'chinese‘)

Page 11: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

11

Symbols represent numbers

Different shapes, different words, different symbols

one ONE one one one 1 1 Roman numerals I and iChinese characters

Zero 0

What ІІ represents depends on the context

Page 12: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

12

Human number systems

Roman system (every so often need a new symbol)I II III IV V VI VII VIII IX XID D DI IL L LI IM M MI

Base ten (ours, Arabic, Indian, …)0 1 2 3 4 5 6 7 8 9 (don’t need new symbols)

10 100 1000 10000 100000 …decimal system (positional base 10)

Page 13: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

13

Number systems

Base "two" – uses two symbols = BinaryThese symbols could be almost anythingCould be written with zeros and ones –

0 and 1 Base "ten" – uses ten symbols = Decimal

could be written with using our usual numerals 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Page 14: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

14

Between Machines & end-users

Machines use binary representations internally

(It's fast, convenient, easy direct and useful)

For end users, machines are designed to convert to the standard representation (0,1,2,3,4,5,6,7,8,9)

Page 15: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

15

Digitising Discrete Information

Digitise – to represent information with digits

Digitise originally meant using the ten numerals ‘0’ through ‘9’

Telephone numbers, National Insurance numbers, etc. are examples of digitised information.

Page 16: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

16

Machines and People

Computing machines {nowadays}manipulate 0s and 1s

Deep in a computer everything is

0s and 1sComputer programsComputer data

People 'manipulate'NumbersWordsImages

Words – spoken language

‘Images’ (symbols) used to represent spoken language (either to

Page 17: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

17

For computers

Computers (internally) represent everything as binary (eg as 0 and 1)

Everything means everything – text, sound, images, computer programmes …

If a computer is used to search through a database and find all those people whose name begins with the letter "G", the most basic representation of the letter G is as some sequence of 0s and 1s

Page 18: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

18

“bits are bits”The same 4 bytes shown can be interpreted differently depending on context.

Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Page 19: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

19

For people

Long (or even relatively short 7±2) sequences of 0s and 1s are very hard for us to read, write, remember, check, communicate with …

We can make quick and easy use of a large number of discrete symbols (but we need to limit the number of symbol chunks that we are handling at any one time)

Page 20: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

20

Ordering Symbols

One advantage of using digits for encoding is that they can be listed in numerical order.

Not always used, however, such as in a telephone book, where listing is by name.

If you use symbols other than digits, you would have to decide on an ordering sequence, called “collating sequence”.

Page 21: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

Discrete / ContinuousRepresentations

Of numbers – binary & decimalBitsHexadecimal - 'Hex'Representing text

Bits and Bytes

Page 22: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

22

Bits For Symbols

Bit stands for binary digit.– A bit is single item of binary information –

We can think of a bit as a single zero or a single one (in some forms of computer memory – it could the presence or absence of an electrical charge at a specific location – it could be the presence or absence of a magnetic charge at a location

Page 23: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

Discrete / ContinuousRepresentations

Of numbers – binary & decimalBits

Decimal and binary againHexadecimal - 'Hex'Representing text

Bits and Bytes

Page 24: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

24

n bits 2n Represent

1 21 2

2 22 4

3 23 8

4 24 16

5 25 32

6 26 64

7 27 128

8 28 256

9 29 512

10 210 1024

A picture will help!

Page 25: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

25

The decimal number 1010

representing one thousand ten = 10 + 1000.

Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Page 26: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

26

The binary number 1010

representing the decimal number ten = 2 + 8.

Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Page 27: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

27

Binary representation of the 1010

the decimal number one thousand ten = 2 + 16 + 32 + 64 + 128 + 256 + 512 Copyright © 2006 Pearson Addison-Wesley. All rights reserved.

Page 28: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

28

Technical

At some points, people need to deal in a convenient manner with the way machines are representing informationMachines are representing it in a binary form

Using just zeros and ones is not handy for us.

The base-10 number systems is not efficient for machines.

Page 29: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

Discrete / ContinuousRepresentations

Of numbers – binary & decimalBitsHexadecimal - 'Hex'Representing text

Bits and BytesContents

Page 30: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

30

Hexadecimal – 'hex'

Base 16Relatively easy for computers

Comparatively easy for us (to read, write, remember, use)

Symbols: 0 1 2 3 4 5 6 7 8 9 a b c d e f

e stands for fourteen

f stands for fifteen

10 stands for sixteen

ff stands for two hundred fifty five

You've seen this with colours

in CSS

Page 31: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

Discrete / ContinuousRepresentations

Of numbers – binary & decimalBitsHexadecimal - 'Hex'

Representing text

Bits and Bytes

Page 32: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

32

The minimum for representing English and numbers Lower-case letters Upper-case letters Some punctuation Blank spaces Frequent symbols

Page 33: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

33

ASCII

American Standard Code for Information Interchange

ASCII was 7 bits –an eighth bit was used for various purposes

it became clear that was not enough bits “Extended” ASCII with 8 bits was developed Eight bits produce 256 symbols which is more

than enough for English and for many European languages

Page 34: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

34

ASCII

Representing 128 different elements

Page 35: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

35

Representation

Page 36: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

36

Representation

Demo!

Page 37: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

37

Bytes & Unicode

IBM gave the 8-bit sequences a special name, byte, and adopted it as a standard unit for computer memory.

Bytes are still the standard unit or memory

The ultimate and complete solution is the representation, called Unicode.It has 8, 16 and 32 bit versions.

It can handle all languages.

Page 38: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

38

Page 39: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

39

Displaying Unicode on PCs

In PowerPoint or word or …

from the menubar

Insert > Symbol > Select Arial Unicode MS

Select Unicode Hex

Demo!

Page 40: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

40

What we need for a global internet

The symbols of all written languages The symbols of basic and useful symbol

systems – Math symbols– IPA "the international phonetic alphabet"

Enough space left over to grow€ (new symbols get added)

Page 41: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

41

And we need these all together

Documents may need to have many languages What about for example an on-line dictionary

(Arabic – Japanese) or … In addition, a developer would want to be able to

build something that would work regardless of the combination of languages needed.

So a unified method of representing all of these together is needed and it is Unicode

Page 42: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

42

Encoding You've seen (and written or copied to

heads of html documents):<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

Another example of this would be:<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Relating it back to HTML etc.

The character set for this document is the Unicode Transformation

Format – 8 bit

Page 43: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

43

Encoding

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Relating it back to HTML etc.

charset means character set

iso-8859-1

iso = “International Standards Organisation”

Page 44: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

44

Symbols & representations

Arabic numerals represent numbersLogos represent companiesə ð ɵ represent sounds√ ℵ ∀ ∃ ∂ ∮ ∈ are used in mathematics¥ ¢ ₨ represent currencies or …ß á â ã ä å À Á Â Ã Ä Å are used in

European languages¶

Page 45: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

45

Some representations are better than others Easier to learn Easier to remember,

easier to store Easier to process

– Roman numerals v arabic numerals

More reliable to communicate

More secure More accurate More precise More flexible

What's easy for people

What's easy for machines

Page 46: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

46

What is a number again?Using numbers as representations Phone numbers License plate

numbers ISBN numbers National Health

insurance numbers

We call these ‘numbers’, We use numerals as their representation, but

We don't add them (or ...)

They don't have an order (my telephone number is lower than yours)

Page 47: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

What does ІІ represent?

It depends on the context

There are at least four reasonable numerical answers that are not just random choices of meaning for ‘I’

Page 48: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

48

Explore on your own

In your textbook, there’s a nice explanation of why ‘bytes’.Have a look. – (Chapter 8 of Snyder Fluency

with Information Technology)

Page 49: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

49

Explore on your own http://www.unicode.org/ http://en.wikipedia.org/wiki/Unicode http://en.wikipedia.org/wiki/Unicode_and_HTML

http://www.columbia.edu/kermit/utf8.html Code charts: http://www.unicode.org/charts/

The absolute minimum every software developer must know […] about Unicode and character setshttp://www.joelonsoftware.com/articles/Unicode.html

Unicode's site http://www.unicode.org/standard/WhatIsUnicode.html On the goodness of unicode

http://www.tbray.org/ongoing/When/200x/2003/04/06/Unicode

Page 50: 1. Discrete / Continuous Representations Of numbers – binary & decimal Bits Hexadecimal - 'Hex' Representing text Bits and Bytes

50