Beruflich Dokumente
Kultur Dokumente
Representation
Real Numbers
Representation
Outline
Real Numbers
Representation
Real Numbers
Representation
Outline
Real Numbers
Representation
Real Numbers
Representation
Real Numbers
Representation
Even practical stu are continuous in nature. Many scientic computation results are real numbers integers simply inadequate!
Real Numbers
Representation
Radix Point
Real Numbers
Representation
Outline
Real Numbers
Representation
Real Numbers
Representation
Question
Is 5.5 = 0101.0101 ?
Real Numbers
Representation
multiply fractional part by 2 integral part of the product is the binary bit remove integral part, keep fractional part repeat from step 1, until fractional part is zero, or desired accuracy is achieved
Real Numbers
Representation
multiply fractional part by 2 integral part of the product is the binary bit remove integral part, keep fractional part repeat from step 1, until fractional part is zero, or desired accuracy is achieved
Example: 0.37510 =???2 0.375 * 2 = 0.75 keep 0 0.75 * 2 = 1.5 keep 1 0.5 * 2 = 1.0 keep 1 0.37510 = 0.0112
Real Numbers
Representation
Going back to previous example: 5.5 = 5.0 and 0.5 5.010 = 1012 0.5 * 2 = 1.0 keep 1 0.510 = 0.12 5.510 = 101.12
Real Numbers
Representation
convert the INTEGRAL PART like before convert the FRACTIONAL part by multiplying to powers of 1/2 Example: convert the binary 10.101 to decimal
Real Numbers
Representation
Outline
Real Numbers
Representation
Real Numbers
Representation
Design Issue
Where do we place the radix point? One way is to place it permanently (in the middle or anywhere we fancy). This is called the FIXED-POINT design.
Real Numbers
Representation
Points to ponder
Does that solution give us exibility? Are our resources ALWAYS well spent?
Real Numbers
Representation
Example
What is the largest integer value can it hold? What is the smallest decimal value can it hold?
Real Numbers
Representation
The solution
Floating point! make the radix point oat, move it around inspired by scientic notation Example: 3.819 x 1085
Real Numbers
Representation
Outline
Real Numbers
Representation
Real Numbers
Representation
The Standard
Why the need for a standard? ensures interoperability between programmers, architects, engineers IEEE Standard 754 dened how oating point numbers are represented
Real Numbers
Representation
Components
What data do we need to represent anyway? Sign Bit Exponent Mantissa
Real Numbers
Representation
Real Numbers
Representation
Component: Exponent
Exponent 8 bits: bit 30 - bit 23 Raised to what? is biased
exponent is really input - 127 why the need for biasing?
It is hard to compare magnitudes of 2C numbers at a glance, the circuit required to do that is complicated. So we use unsigned numbers instead. But without biasing signed numbers could not represent negative numbers! Hence the need for biasing.
exponents that are all ALL ZEROES and ALL ONES reserved for SPECIAL numbers
Real Numbers
Representation
Component: Mantissa
Mantissa 23 bits: bit 22 - bit 0 Actual number in Scientic Notation, only ONE digit must be on the RIGHT of the radix point could we take advantage of binary being binary?
YES.
Real Numbers
Representation
Component: Mantissa
no need to represent what is on the left side of the radix point - OBVIOUS!
Real Numbers
Representation
Component: Mantissa
no need to represent what is on the left side of the radix point - OBVIOUS! - Its always 1
Real Numbers
Representation
Component: Mantissa
no need to represent what is on the left side of the radix point - OBVIOUS! - Its always 1 we get to use ALL 23 bits in representing what is on the RIGHT. In eect, we could represent 24 bits with just 23!
Real Numbers
Representation
Floating Point
Real Numbers
Representation
Example
Real Numbers
Representation
Example
If 81500000 is a IEEE 754 representation(in HEX) of a number, what is the number? Convert to binary: 1000 0001 0101 0000 0000 0000 0000 0000
Real Numbers
Representation
Example
If 81500000 is a IEEE 754 representation(in HEX) of a number, what is the number? Convert to binary: 1000 0001 0101 0000 0000 0000 0000 0000 Group together: 1 00000010 10100000000000000000000
Real Numbers
Representation
Example
If 81500000 is a IEEE 754 representation(in HEX) of a number, what is the number? Convert to binary: 1000 0001 0101 0000 0000 0000 0000 0000 Group together: 1 00000010 10100000000000000000000 SIGN = 1 -> -1 EXPONENT = 00000010 -> 2, so 2 - 127 = -125 MANTISSA = 10100000000000000000000 -> 1.101
Real Numbers
Representation
Example
If 81500000 is a IEEE 754 representation(in HEX) of a number, what is the number? Convert to binary: 1000 0001 0101 0000 0000 0000 0000 0000 Group together: 1 00000010 10100000000000000000000 SIGN = 1 -> -1 EXPONENT = 00000010 -> 2, so 2 - 127 = -125 MANTISSA = 10100000000000000000000 -> 1.101 Answer: 1.1012 x 2125
Real Numbers
Representation
Example
If 81500000 is a IEEE 754 representation(in HEX) of a number, what is the number? Convert to binary: 1000 0001 0101 0000 0000 0000 0000 0000 Group together: 1 00000010 10100000000000000000000 SIGN = 1 -> -1 EXPONENT = 00000010 -> 2, so 2 - 127 = -125 MANTISSA = 10100000000000000000000 -> 1.101 Answer: 1.1012 x 2125 or 1.62510 x 2125
Real Numbers
Representation
Assignment
Research and study on the following: IEEE 754 double-precision Converting from non-IEEE to IEEE Why bias is 127? Do we still use 2C on IEEE 754?