Factional Values What is 0.75 in binary?
How could we represent fractions? In decimal: – As fractions : 1/5
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 hundredths
Column Pattern What goes to the right of 1’s column?
Column Pattern
Number Binary decimal: = =
Number Binary decimal: = =
Number Binary decimal: = =
Missing Numbers Where is 0.6? = = = =
An attempt with 11 decimal digits: Can only approximate More Digits Binary Decimal Place Bit Value Total
Decimals are an Approximation Decimal has same issue: – What is 1/3 ?? – What is 2/7 ??
More Digits Given limited digits, must allocate them – To left of decimal: Bigger values – To right of decimal: More accurate values
Fixed Decimal Problems Fixed decimal points waste space: 400,000,000,000,000,
Fixed Decimal Problems Fixed decimal points waste space: 400,000,000,000,000,000 vs 4.0 x vs 2.5 x In computers, space is precious – Computers use a floating decimal point (Like scientific notation)
Floating Point Bits used to represent 3 parts: – Sign – Exponent – Fraction (or Mantissa) SignExponentMantissa
Sign 0 = positive, 1 = negative SignExponentMantissa
Exponent Binary integer in excess notation – Gives power of 2 to multiply by 100 = 0 So 2 0 SignExponentMantissa BinaryValue
Mantissa Fractional Value – Always a decimal 1000 = 0.5 SignExponentMantissa
Examples x 0.5 = + 1 x 0.5 = SignExponentMantissa so
Examples x = - 8 x = -4.5 SignExponentMantissa so
Examples x 0.25 = x 0.25 = SignExponentMantissa
Floating Point Math is HARD XOR the signs Calculate new exponent – Excess Notation – different math rules! Calculate new mantissa – Normal binary multiplication SignExponentMantissa
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?
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:
Remember… Decimals are approximate 32 bit float gives 6-7 significant decimal digits 64 bit float gives significant decimal digits