[SOLVED] 程序代写 IEEE 754 standard

30 $

File Name: 程序代写_IEEE_754_standard.zip
File Size: 282.6 KB

SKU: 6695157321 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


1007ICT / 1807ICT / 7611ICT Computer Systems & Networks
Lecture 5: Decimal real numbers

Last Section: The Processor

Copyright By PowCoder代写加微信 assignmentchef

Topics covered:
⚫ Central Processing Unit (CPU)
⚫ Arithmetic Logic Unit (ALU)
⚫ Registers
⚫ Data, instructions and instruction sets
⚫ Micro programs and the processor datapath
⚫ The fetch / decode / execute cycle
⚫ Input / Output models
⚫ Interrupts
©. Revised and updated by,, and Wee Lum 2

Lecture Content
Topics Covered:
⚫ Learning objectives
⚫ Decimal real numbers
⚫ Fixed point binary
⚫ Converting fractions
⚫ Floating point numbers
⚫ Exponential notation
⚫ IEEE Floating point formats ⚫ IEEE Normalisation
⚫ IEEE Examples
©. Revised and updated by,, and Wee Lum 3

Learning Objectives
In this lecture you will have:
⚫ Learnt how to represent decimal real numbers
⚫ Learnt how to represent fixed point binary
⚫ Learnt how to convert decimal fractions to binary and vice versa
⚫ Gainedanunderstandingofbinaryfloating point numbers
⚫ Learnt how to represent numbers using exponential notation
⚫ Learnt how to represent binary floating point numbers using an IEEE Floating point format
⚫ Learnt how to represent binary floating point numbers in normalised form
©. Revised and updated by,, and Wee Lum 4

Decimal Real Numbers (Section 4.3)
⚫ Real numbers, in particular fractions, are important
⚫ When dealing with decimal real numbers, the whole number and fractional parts are separated by a “decimal point”, e.g. 123.45
⚫ The place of each digit gives the power of 10 that the value of the digit represents
Place/Power 2 1 0 -1 -2
10-1 = 10-2 = 10-3 = 10-4 = 10-5 =
1 x 100 = 100
+ 2 x 10 = 20
+ 3x 1 = 3
+ 4 x 0.1 = 0.4
+ 5 x 0.01 = 0.05
1/10 = 1/100 = 1/1000 = 1/10,000 = 1/100,000 =
0.1 0.01 0.001 0.0001 0.00001
©. Revised and updated by,, and Wee Lum 5

Two models for decimal real numbers
⚫ We will discuss two models for representing decimal real numbers
1. Fixed point binary 2. IEEE 754 standard
©. Revised and updated by,, and Wee Lum 6

Fixed Point Binary
⚫ We can represent real numbers in binary by separating the whole and fractional parts of the number by using a binary point “.” e.g., 01001.11001
⚫ For any given word size you need to decide how many bits will be on left side of the “.” this determines both what the biggest number and what the smallest fraction that can be represented will be.
⚫ For example with a 16 bit word you could use 8.8 format so that the biggest unsigned number is 255 and the smallest fraction is 1/256 = 0.00390625
⚫ The place of each digit gives the power of 2 that the value of the digit represents
Whole (8 bits)
Fractional (8 bits)
Place/Power
©. Revised and updated by,, and Wee Lum 7

Fixed Point Binary
Place/Power
Whole (8 bits) Fractional (8 bits)
⚫ For example lets look at the binary number
⚫ 110110.1010
= 1*25 + 1*24 + 0*23 + 1*22 + 1*21 + 0*20 +
= 1*32 + 1*16 + 0*8 + 1*4 + 1*2 + 0*1 + = 54 5/8
⚫ Note: 2-1 = 1⁄2; 2-2 = 1⁄4; 2-3 = 1/8;
2-4 = 1/16 etc
1*2-1 + 0*2-2 + 1*2-3 + 0*2-4
1*1⁄2 + 0*1⁄4 + 1*1/8 + 0*1/16
2-4 = 2-5 = 2-6 =
1/16 = 1/32 = 1/64 =
0.0625 0.03125 0.015625
2-1 = 2-2 = 2-3 =
1/2 = 0.5 1/4 = 0.25 1/8 = 0.125
©. Revised and updated by,, and Wee Lum 8

Converting Fractions
⚫ You can convert binary to decimal fractions by:
1. Shift the binary point right to the end of the fraction (remember how
many places )
2. Convert the whole binary number to a whole decimal number. 3. Divide the decimal number by 2places
E. g. convert 0.1011012 to decimal:
1. Shift binary point 6 places right: 01011012
2. Convert: 32 + 8 + 4 + 1 = 45
3. Divide 45 by 2places = 45  26 = 45/ 64 = 0.70312510
⚫ You can convert from decimal to binary fractions by: 1. Multiply the decimal fraction by 2
2. Save the digit to the left of the point as a result
3. Drop the digit to the left of the point
4. Repeat 1,2,3 until the value 1.0000 is reached ©. Revised and updated by,, and Wee Lum 9

Example: Decimal→Binary Fraction Convert 0.70703125 to binary:
0.70703125 ×2 0.4140625 ×2 0.828125 ×2 0.65625 ×2 0.3125 ×2 0.625 ×2 0.25 ×2 0.5 ×2
The resulting binary
results, in order, from left to right: 0.101101012
©. Revised and updated by,, and Wee Lum 10
= 1.4140625 then save and drop 1 = 0.828125 then save and drop 0 = 1.65625 then save and drop 1 = 1.3125 then save and drop 1 = 0.625 then save and drop 0 = 1.25 then save and drop 1 = 0.5 then save and drop 0 = 1.0 then save 1
fraction is read by appending the partial

Exponent-mantissa format
⚫ The main problem with fixed point numbers is that if we want to represent either very small fractions or very large numbers we need to use lots of bits.
⚫ One alternative is to use a variable number of bits to represent real numbers but this would make processing extremely complicated if not impossible.
⚫ The other alternative is an exponent–mantissa format E.g.: represent -0.0000003579 in exponent format
(normal form) sign of exponent sign of mantissa
mantissa -3.579 x 10-7 exponent base
©. Revised and updated by,, and Wee Lum 11

Exponential Notation
⚫ Different scientific notation representations of the same number may be generated by shifting the decimal point left or right and adjusting the exponent value to suit.
⚫ To maintain the same value, every place to the right that you move the decimal point, you should decrease the exponent by one.
⚫ Similarly, for each place to the left that you move the decimal point, you should increase the exponent by one.
Normalised form
⚫ Normalised form has 1 digit (non-zero) before the decimal place (Eg. A.BCDEF x 10x)
433456 = 433456 x 100 = 4.33456 x 105 (normalised form) 0.001102 = 0.001102 x 20 = 1.102 x 2-3 (normalised form)
©. Revised and updated by,, and Wee Lum 12

IEEE Floating Point Formats
⚫ Unlike integer representations, a certain number of bits must be allocated to the exponent and its sign and the remainder to the mantissa and its sign.
⚫ There are a number of formats depending upon the particular type of computer/ operating system being used. A format commonly used on Intel and Macintosh PCs is the IEEE Standard 754.
⚫ The IEEE standard has a 32- bit, single precision, and 64- bit, double precision, format for binary floating point numbers.
⚫ A 32- bit single precision floating point binary number is divided into the following:
⚫ 1bit -sign of mantissa
⚫ 8 bit exponent
⚫ 23 bit mantissa
©. Revised and updated by,, and Wee Lum 13

IEEE Floating Point Formats
⚫ A number of parts that were in the scientific notation, are missing here! This is because this information is somehow implied by the structure of the number.
⚫ The mantissa is stored in what is called ‘normalized’ form. In this form the leading bit is always a ‘1’ and the position of the binary point is always the same so they can be assumed and need not be stored.
⚫ The exponent is stored in what is called ‘excess-127’ notation (biased exponent with k = 127)
⚫ This format eliminates the need for a separate sign bit for the exponent.
⚫ The exponent +3 will be stored as 127 + 3 = 130
⚫ The exponent -11 will be store as 127 – 11 = 116
⚫ Exponentvaluesof0and255arereservedforspecial circumstances leaving an exponent range of: 2-126 to 2127
©. Revised and updated by,, and Wee Lum 14

IEEE Floating Point Normalisation
To normalize a binary number for IEEE 754 format:
⚫ 1. Set the exponent to zero (0)
⚫ 2. Shift the binary point left or right until the binary number starts with 1. mmmm
⚫ 3. Adjust the exponent to maintain the original value
⚫ 4. Discard the least significant bits of the mantissa or add trailing zeroes to keep the number at the specified size (23 digits)
©. Revised and updated by,, and Wee Lum 15

IEEE Normalisation Examples
⚫ 1101110.001111001 1. Initialise exponent = 0
2. (Normalise) Shift binary point until = 1.101110001111001 3. Adjust exponent = +6
4. Add trailing 0s = 1.10111000111100100000000
⚫ 0.0011000111
1. Initialise exponent = 0
2. (Normalise) Shift binary point until = 1.1000111 3. Adjust exponent = -3
4. Add trailing 0s = 1.10001110000000000000000
©. Revised and updated by,, and Wee Lum 16

IEEE Creation Example
⚫ Converting from decimal to IEEE floating point.
275,005.2510 = 1000011001000111101.012
⚫ 1.(Normalise)Initialiseexponent=0
⚫ 2. Shift binary point = 1.00001100100011110101
⚫ 3.(Generateexponent)Adjustexponent=18 ⚫ 1. Excess- 127 = 127 + 18 = 145
⚫ 2. In binary = 10010001
⚫ 4.Mantissa(droptheleading1)=00001100100011110101
⚫ 5. Pad to 23 bits (add 0s)= 00001100100011110101000
⚫ 6. Sign = 0 (positive)
⚫ 32-bitIEEEformatis:
⚫ 01001000100001100100011110101000
sign exponent mantissa
©. Revised and updated by,, and Wee Lum 17

IEEE unpacking Example
⚫ Converting from IEEE floating point format to decimal.
⚫ Let’s start with a 32- bit number in IEEE format: ⚫1
10101110100111110101100
The first bit (1) tells us that the number is negative.
The next eight (8) bits 10110011 1. Evaluate to: 179
2. Excess- 127: 179 – 127 = 52
3. Exponent is: 52
The remaining 23 bits are the normalized mantissa:
10101110100111110101100
The leading “1.” is implied so mantissa is: 1.10101110100111110101100
1. Initialise places to 0
2. Move binary point 23 places to the right: 110101110100111110101100.0 3. Numerator is 1101011101001111101011002 = 1411063610
4. Denominator is 223 = 8388608 (we shifted 23 times to the right)
5. Numerator/ Denominator = 1.68211889267
5. Decimal real number = -1.68211889267 ×252
Note: This number is still represented as a power of 2, normally we would convert it to a power of 10
Convert 23 bit mantissa to decimal:
©. Revised and updated by,, and Wee Lum 18

Importance of type declaration
⚫ As you can see, one 32- bit number looks much the same as any other; eg 11011001110101110100111110101100
⚫ The above number could be interpreted as an integer, string of characters or any number of other formats. The key, as with integers and characters, is that the computer must know what kind of data it is to decode it successfully.
⚫ If interpreted as an:
⚫ IEEE floating point number we get: -1.68211889267 ×2 52
⚫ unsigned integer we get: 3654766508
⚫ a 2’s complement number we get: -640200788
©. Revised and updated by,, and Wee Lum 19

Have studied:
⚫ Decimal real numbers
⚫ Fixed point binary
⚫ Converting fractions
⚫ Floating point numbers
⚫ Exponential notation
⚫ IEEE Floating point formats ⚫ IEEE Normalisation
⚫ IEEE Examples
©. Revised and updated by,, and Wee Lum 20

⚫ Memory organisation
©. Revised and updated by,, and Wee Lum 21

程序代写 CS代考加微信: assignmentchef QQ: 1823890830 Email: [email protected]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 程序代写 IEEE 754 standard
30 $