Download presentation
Presentation is loading. Please wait.
Published byHope Flynn Modified over 9 years ago
1
CSC 4250 Computer Architectures September 5, 2006 Appendix H. Computer Arithmetic
2
Integers Using an 8-bit pattern, how many different integers can we represent? 2 8 Correct? How can we represent negative integers? Use a sign bit How many different integers are there?
3
Small Numbers How can we represent numbers that are smaller than 1?
4
Fixed Point Data Type Bit pattern:0100 0010 Binary point just to the right of sign bit (in text) Can be anywhere inside bit pattern Binary point to far right of bit pattern What do we get? Integer Value of bit pattern as integer:0100 0010 Value of bit patt. as fixed point:0100 0010
5
Blocked Floating Point Fixed point → Low cost floating point Exponent kept in separate variable Exponent shared by a set of fixed point variables Applications? Overflow?
6
Saturating Arithmetic In DSP, if result is too large to be represented, it is set to the largest representable number with the appropriate sign What happens when we get a floating-point overflow?
7
IEEE 754 Floating-Point (32 bit) Value=(–1) s (1+f) 2 (e–127) Significand =1+f Compare: scientific notation, say 3.45 × 10 6 Base=2 So, 13 is represented by1.101 × 2 3 withs=0, e=10000010, f=10100…00 Can you give one advantage of the implicit 1? Can you give one disadvantage of the implicit 1? 3130 29 … 24 2322 21 20 19 18 17 … 5 4 3 2 1 0 se: exponentf: fraction 1 bit 8 bits 23 bits
8
IEEE 754 Floating-Point (64 bit) 1 bit 11 bits 52 bits Value=(–1) s (1+f) 2 (e–1023) Significand =1+f 6362 61 … 53 5251 50 49 48 … 4 3 2 1 se : exponentf : fraction
9
Base IEEE:2 Other bases:16IBM 8Burroughs Normalize such that the first digit is nonzero For base 16, the first digit could be 1, 2, …, 14, 15 Need new symbols to represent 10,11, 12, 13, 14, 15 What is base 16 called?
10
Hexadecimal What is hexa? Greek for six What is decimal? Latin for ten What is Latin prefix for six? Sexa What is old name for base 16? Sexidecimal Which company changed the name?
11
Hexadecimal System For base 16, we have 1 = 1/16 × 16 1 withf = 0001 00…00, 2= 2/16 × 16 1 withf = 0010 00…00, 4 = 4/16 × 16 1 withf = 0100 00…00, 8 = 8/16 × 16 1 withf = 1000 00…00, 16= 1/16 × 16 2 withf = 0001 00…00, Disadvantage:As many as three leading zero bits Advantage:Base larger → Range larger 32 bit FP rep.:1 sign bit, 7 exp. bits, 24 fraction bits (exponent bias = 64).
12
Floating Point Representation of 1 IEEE: s = 0, e = 01111111, f = 00000…00; Value=(1) 2 (127–127) = 1. IBM Hexadecimal: s = 0, e = 1000001, f = 00010000…00; Value=(1/16) 16 (65–64) = 1.
13
IEEE FP Representation of One to Sixteen Numbersef 100111111100000000000000000000000 201000000000000000000000000000000 301000000010000000000000000000000 401000000100000000000000000000000 501000000101000000000000000000000 601000000110000000000000000000000 701000000111000000000000000000000 801000001000000000000000000000000 901000001000100000000000000000000 1001000001001000000000000000000000 1101000001001100000000000000000000 1201000001010000000000000000000000 1301000001010100000000000000000000 1401000001011000000000000000000000 1501000001011100000000000000000000 1601000001100000000000000000000000
14
Integer Comparisons of FP Number Ease to use Sorting Sign bit is most significant: Easy to check if number is greater than, less than, or equal to zero Exponent before fraction: Larger exponent → larger number Use bias such that exponent values ≥ 0 1 ≤ e ≤ 254 → –126 ≤ e – bias ≤ 127 e = 0 and e = 255?
15
Representation of Zero All bits (except sign bit) equal zero e = 0 → zero exponent field Zero fraction field (no implicit 1) Plus and minus zero
16
Denormal Numbers e = 0 → zero exponent field f ≠ 0 → no implicit 1 Value = (–1) s *f *2 –126 Gradual underflow
17
IEEE Representation Fill in the blanks Numbersef 0 1 2 –1 2 –2 2 –125 2 –126 2 –127 2 –128 2 –129 2 –149
18
Underflow to Zero In old days, a FP number that underflowed could be set to zero An old “fast” test for equality: If a − b = 0, then a = b Test would fail if a − b underflowed
19
Infinity e = 11…1 → maximum exponent field Zero fraction field Plus and minus infinity 1/0 = ∞; 1+∞ = ∞ Useful in trigonometry: sin(tan –1 ∞) = sin π/2 = 1
20
NaN Not a Number e = 11…1 → maximum exponent field Nonzero fraction field Can you give an operation that generates NaN? What is 1+NaN?
21
Examples Largest positive number: s = 0, e = 11111110, f = 11111…11; Value=(1+2 –1 +…+2 –23 ) 2 (254–127) =(2−2 –23 ) 2 127 ≈ 2 128 ≈ 2.56×10 38 One: s = 0, e = 01111111, f = 00000…00; Value=(1) 2 (127–127) = 1. Smallest positive normal number: s = 0, e = 00000001, f = 00000…00; Value=(1) 2 (1–127) =2 –126 ≈ 1.6×10 –38
22
Examples (2) Largest positive denormal number: s = 0, e = 00000000, f = 11111…11; Value=(2 –1 +…+2 –23 ) 2 –126 =(1−2 –23 ) 2 –126 ≈ 2 –126 Differs from smallest normal by 2 –149 Smallest positive denormal number: s = 0, e = 00000000, f = 00000…01; Value=(2 –23 ) 2 –126 = 2 –149 ≈ 2×10 –45 Plus zero: s = 0, e = 00000000, f = 00000…00.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.