Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mathematics for Computing Lecture 1: Numerical Representation Dr Andrew Purkiss-Trew Cancer Research UK

Similar presentations


Presentation on theme: "Mathematics for Computing Lecture 1: Numerical Representation Dr Andrew Purkiss-Trew Cancer Research UK"— Presentation transcript:

1 Mathematics for Computing Lecture 1: Numerical Representation Dr Andrew Purkiss-Trew Cancer Research UK e-mail: a.purkiss@mail.cryst.bbk.ac.uk

2 Course Information 2007-08 Numerical Representation Logic Algorithms and flow charts Set theory Relations Functions

3 Lecture / tutorial plans Lecture every week in room SHB29 (1 – 2½ hours) Tutorial every other week in room SHB29 (1 – 1½ hours)

4 Provisional Timetable DateWeekTopic 01/10/071Introduction and Numerical Representation 08/10/072Logic 1 / Tutorial 1 15/10/073Logic 2 22/10/074Algorithms & Flowcharts / Tutorial 2 29/10/075Set Theory 1 05/11/076Set Theory 2 / Tutorial 3 12/11/077Relations 1 19/11/078Relations 2 / Tutorial 4 26/11/079Functions 1 03/12/0710Functions 2 / Tutorial 5 10/12/0711Mock examination / hand out of coursework

5 Versions of the number six Decimal: 6Alphabetically: six Roman: VI Tallying: Versions of one and a quarter: Mixed number: 1¼, Improper fraction: 5/4, Decimal: 1.25 Representation of numbers

6 Types of numbers Natural numbers: 1, 2, 3, 4, … Integers: …, -3, -2, -1, 0, 1, 2, 3, … Rational numbers: m/n, where m and n are integers and n  0. Examples: ½, 5/3, ¼ = 0.25 1/3 = 0.3333… Irrational numbers, examples:  2  1.414,   22/7, e  2.718.

7 Decimal numbers (base 10) String of digits - symbol for negative numbers Decimal point A positional number system. Example: 3583.102 = 3 x 10 3 + 5 x 10 2 + 8 x 10 1 + 3 x 10 0 + 1 x 10 -1 + 0 x 10 -2 + 2 x 10 -3

8 Other number systems Bases can be any natural number except 1. Example of time in seconds: 3hrs 13mins 45secs = 3 x 60 2 + 13 x 60 1 + 45 x 60 0 seconds. Binary (base 2), Octal (base 8) and hexadecimal (base 16) 101 2 = 1 x 2 2 + 0 x 2 1 + 1 x 2 0 = 5 10

9 The binary system Base 2 Digits 0 and 1 Example: 11011011 2   msd lsd

10 Some binary numbers!!! BinaryDecimalBinaryDecimalBinaryDecimal 001117111014 1110008111115 102100191000016 1131010101000117 10041011111001018 10151100121001119 11061101131010020

11 Octal Base eight Digits 0,1,2,3,4,5,6,7 Example: 12 10 = 14 8 = 1100 2 10011011110 2 Binary 2 3 3 6 = 2336 8 Octal

12 Hexadecimal Base sixteen Digits 0,1,2,3,4,5,6,7,8,9,A(10), B(11), C(12),D(13),E(14),F(15). Example B3 16 = 179 10 = 10110011 2 11010101 2 Binary D 5 Hexadecimal

13 Computer representation Fixed length Integers Real Sign

14 Bits, bytes, words Bit: a single binary digit Byte: eight bits Word: Depends!!! Long Word: two words

15 Integers A two byte integer 16 bits 2 16 possibilities  65536 -32768  n  32767 or 0  n  65535

16 Signed integers First bit is sign bit. n  0, 0; n < 0, 1 For n  0, 15 bits are binary n For n < 0, 15 bits are binary (n + 32768) Example: -6772 10 (-001101001110100 2 ) 1000000000000000 2 -001101001110100 2 110010110001100 2

17 32bit word Big and little ends Big End 0123 4567 891011 12131415 ANDY P 8bit byte 32bit word Little End 3210 7654 111098 15141312 YDNA P 8bit byte

18 Real numbers ‘Human’ form: 4563.2835 Exponential form: 0.4563 x 10 4 General form:  m x b e Normalised binary exponential form:  m x 2 e Another example: 6.02 x 10 23

19 Real numbers 2 For a 32 bit real number Sign, 1 bit Significand, 23 bits Exponent, 8 bits Exponent bias: 2 n-1 -1, where n is the number of bits

20 Decimal to Binary conversion 1 n div 2 is the quotient. n mod 2 is the remainder. For example: 14 div 2 = 7, 14 mod 2 = 0 17 div 2 = 8, 17 mod 2 = 1

21 Decimal to Binary conversion 2 1. Input n (natural no.) 2. Repeat 2.1.Output n mod 2 2.2.n  n div 2 until n = 0 Example: 11 10 Stepnoutput 111- 2.1111 2.25- 2.151 2.22- 2.120 2.21- 2.111 2.20-

22 Decimal to Binary conversion 3 1. Input n 2. Repeat 2.1.m  2n 2.2.Output  m  2.3. n  frac(m) until n = 0  m  is the integer part of m frac(m) is the fraction part. Example: 0.375 10 Stepmnoutput 1-0.375- 2.10.750.375- 2.20.750.3750 2.30.750.75- 2.11.50.75- 2.21.50.751 2.31.50.5- 2.110.5- 2.210.51 2.310-

23


Download ppt "Mathematics for Computing Lecture 1: Numerical Representation Dr Andrew Purkiss-Trew Cancer Research UK"

Similar presentations


Ads by Google