Download presentation
Presentation is loading. Please wait.
Published byJocelyn Shields Modified over 9 years ago
1
Factional Values What is 0.75 in binary?
2
How could we represent fractions? In decimal: – As fractions : 1/5
3
How could we represent fractions? In decimal: – As fractions : 1/5 – As decimals : 0.2 hundreds 10 2 tens 10 1 ones 10 0 tenths 10 -1 hundredths 10 -2 0 20
4
Column Pattern What goes to the right of 1’s column? 2382382 224224 212212 201201
5
Column Pattern 2382382 224224 212212 201201 2 -1 0.5 2 -2 0.25 2 -3 0.125 2 -4 0.0625
6
Number Binary decimal: 10.11 2 = 2 + 0.5 + 0.25 = 2.75 10 2382382 224224 212212 201201 2 -1 0.5 2 -2 0.25 2 -3 0.125 2 -4 0.0625 1011
7
Number Binary decimal: 0.1001 2 = 0.5 + 0.0625 = 0.5625 10 2382382 224224 212212 201201 2 -1 0.5 2 -2 0.25 2 -3 0.125 2 -4 0.0625 01001
8
Number Binary decimal: 0.1010 2 = 0.5 + 0.125 = 0.625 10 2382382 224224 212212 201201 2 -1 0.5 2 -2 0.25 2 -3 0.125 2 -4 0.0625 01010
9
Missing Numbers Where is 0.6? 0.1001 2 = 0.5 + 0.0625 = 0.5625 10 0.1010 2 = 0.5 + 0.125 = 0.625 10
10
An attempt with 11 decimal digits: Can only approximate More Digits Binary Decimal Place 2 -1 2 -2 2 -3 2 -4 2 -5 2 -6 2 -7 2 -8 2 -9 2 -10 2 -11 Bit 10011001101 Value 0.5000.06250.03125000.0039060.00195300.000488 Total0.600098
11
Decimals are an Approximation Decimal has same issue: – What is 1/3 ?? – What is 2/7 ??
12
More Digits Given limited digits, must allocate them – To left of decimal: Bigger values – To right of decimal: More accurate values 2 5 32 2 4 16 2382382 224224 212212 201201 2 -1 0.5 2 -2 0.25 212212 201201 2 -1 0.5 2 -2 0.25 2 -3 0.125 2 -4 0.0625 2 -5 0.03125 2 -6 0.015625
13
Fixed Decimal Problems Fixed decimal points waste space: 400,000,000,000,000,000 0.000000000000025
14
Fixed Decimal Problems Fixed decimal points waste space: 400,000,000,000,000,000 vs 4.0 x 10 17 0.000000000000025 vs 2.5 x 10 -14 In computers, space is precious – Computers use a floating decimal point (Like scientific notation)
15
Floating Point Bits used to represent 3 parts: – Sign – Exponent – Fraction (or Mantissa) SignExponentMantissa 01001000
16
Sign 0 = positive, 1 = negative SignExponentMantissa 01001000
17
Exponent Binary integer in excess notation – Gives power of 2 to multiply by 100 = 0 So 2 0 SignExponentMantissa 01001000 BinaryValue 000-4 001-3 010-2 011 1000 1011 1102 1113
18
Mantissa Fractional Value – Always a decimal 1000 = 0.5 SignExponentMantissa 01001000 2 -1 0.5 2 -2 0.25 2 -3 0.125 2 -4 0.0625 1000
19
Examples + 2 0 x 0.5 = + 1 x 0.5 = + 0.5 SignExponentMantissa 01001000 +0 so 2 0 0.5 2 -1 0.5 2 -2 0.25 2 -3 0.125 2 -4 0.0625 1000
20
Examples - 2 3 x 0.5625 = - 8 x 0.5625 = -4.5 SignExponentMantissa 11111001 -3 so 2 3 0.5625 2 -1 0.5 2 -2 0.25 2 -3 0.125 2 -4 0.0625 1001
21
Examples + 2 -4 x 0.25 = + 0.0625 x 0.25 = +0.015625 SignExponentMantissa 00000100 +0.25 2 -1 0.5 2 -2 0.25 2 -3 0.125 2 -4 0.0625 0100
22
Floating Point Math is HARD XOR the signs Calculate new exponent – Excess Notation – different math rules! Calculate new mantissa – Normal binary multiplication SignExponentMantissa 01001000
23
Choices, choices Choices – More bits to exponent – More bits to mantissa – How we represent each What is our excess start point? Do mantissas have to start with 1?
24
32 Bit Floating Point PC processors are 32 or 64 bit – Size of data they can work on at one time IEEE specifies conventions for floating points:
25
Remember… Decimals are approximate 32 bit float gives 6-7 significant decimal digits 64 bit float gives 15-16 significant decimal digits
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.