Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cosc 2P12 Week 2.

Similar presentations


Presentation on theme: "Cosc 2P12 Week 2."— Presentation transcript:

1 Cosc 2P12 Week 2

2 Some Definitions Rational Number Irrational Number Terminating Decimal
Can be represented by dividing 2 integers, E.g. A/B Irrational Number Cannot be represented by dividing 2 integers. Number is a non-terminating non repeating decimal. E.g. Pi, sqrt(2). Terminating Decimal Rational Numbers which have a terminating decimal equivalent Non-Terminating Rational numbers Contain a repeating sequence of numbers, call the Reptend

3

4 Goals of Integer Representation

5 Unsigned base ten base two 0 0000 1 0001 2 0010 3 0011 4 0100 … 8 1000

6 Sign Magnitude left bit is for the sign 0 for positive 1 for negative
remaining bits for the magnitude e.g = = -3

7 One's Complement to change the sign:
toggle all bits i.e. 1--> 0 0-->1 e.g = = -3 note: zero has two representations 0000 = = - 0

8 Two's Complement to change the sign:
toggle all bits i.e. 1--> 0 0-->1 and then add 1 e.g = +3 = 1101 = -3 note: largest positive number (in 4 bits) is 0111 = +7 1000 = -8 is the largest negative number

9 Biased Representation
Subtract a constant value (the bias) from the unsigned interpretation For a 3 bit representation with a bias of 4 range of unsigned is range of biased is

10 Negative Numbers

11 Notes on Integer Representation
positive integers are represented the same in all but biased S-M & complements msb is the sign (0 for +, 1 for -) two's comp. & bias 128 represent the same values except msb is inverted

12 Sign Extension Typical Integer Representations are 8, 16, 32, 64 bits.
We want to: Change a smaller representation to a larger one. Representations unsigned sign-magnitude complement

13

14 Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex | Char Dec Oct Hex
(nul) x00 | (sp) x x40 | ` x60 (soh) x01 | ! x21 | A x41 | a x61 (stx) x02 | " x22 | B x42 | b x62 (etx) x03 | # x23 | C x43 | c x63 (eot) x04 | $ x24 | D x44 | d x64 (enq) x05 | % x25 | E x45 | e x65 (ack) x06 | & x26 | F x46 | f x66 (bel) x07 | ' x27 | G x47 | g x67 (bs) x08 | ( x28 | H x48 | h x68 (ht) x09 | ) x29 | I x49 | i x69 (nl) x0a | * x2a | J x4a | j x6a (vt) x0b | x2b | K x4b | k x6b (np) x0c | , x2c | L x4c | l x6c (cr) x0d | x2d | M x4d | m x6d (so) x0e | x2e | N x4e | n x6e (si) x0f | / x2f | O x4f | o x6f (dle) x10 | x30 | P x50 | p x70 (dc1) x11 | x31 | Q x51 | q x71 (dc2) x12 | x32 | R x52 | r x72 (dc3) x13 | x33 | S x53 | s x73 (dc4) x14 | x34 | T x54 | t x74 (nak) x15 | x35 | U x55 | u x75 (syn) x16 | x36 | V x56 | v x76 (etb) x17 | x37 | W x57 | w x77 (can) x18 | x38 | X x58 | x x78 (em) x19 | x39 | Y x59 | y x79 (sub) x1a | : x3a | Z x5a | z x7a (esc) x1b | ; x3b | [ x5b | { x7b (fs) x1c | < x3c | \ x5c | | x7c (gs) x1d | = x3d | ] x5d | } x7d (rs) x1e | > x3e | ^ x5e | ~ x7e (us) x1f | ? x3f | _ x5f | (del) x7f

15

16

17 Floating Point Representation
IEEE FPS (Floating Point Standard) exponent - 8 bit biased integer mantissa - normalized, scaled, sign-magnitude integer scaled - mantissa is implicitly divided by a constant ( 2 23) S exponent fraction (mantissa) 1 bit 8 bits 23 bits N = (-1)S x 1.fraction x 2exponent - 127

18 Hidden Bit m = 1.b-1b-2b-3•••b-22b-23 two
Since we know m  1 < 2 (b0) we don’t have to represent it. b0.b-1b-2b-3•••b-22b-23 two So all we Store is: b-1b-2b-3•••b-22b-23 two

19 Representation in IEEE FPS
SEF S - sign of the significand E - referred to as exponent F - fractional part of significand e - true exponent (E -127)

20 Representing Zero Since b0 is not stored we need another method
Reserve -127 of Exponent Forces Exp to be pos unsigned integer, because of bias FPS defines 0 as Mantissa=Exp=0 F=E=0 in SEF standard

21

22 Short FP

23 Long FP

24 Extended FP Numbers

25 Conversion to Floating Point
Break decimal number into two parts. Convert integer part to binary Convert fraction to binary Put the two pieces back together Normalize and put into Scientific Notation E.g

26 Converting from FPS Extract the sign bit, the exponent, and the fraction. Place a 1 in front of the fraction giving the normalized value 1.fraction Subtract 127 from the exponent giving the actual exponent. Shift the decimal place right (positive exponent) or left (negative exponent) the required number of places Convert to decimal

27 FPS Standard

28 End


Download ppt "Cosc 2P12 Week 2."

Similar presentations


Ads by Google