SlideShare a Scribd company logo
1 of 53
Unit 2
von Neumann/Turing
• Stored Program concept
• Main memory storing programs and data
• ALU operating on binary data
• Control unit interpreting instructions from
  memory and executing
• Input and output equipment operated by
  control unit
• Princeton Institute for Advanced Studies
    —IAS
• Completed 1952
Structure of von Neumann machine
• Structure of IAS –
  detail
• MemoryAddressRegister(MAR)-This register holds the
  address of the memory location to be accessed. The
  desired address is loaded into MAR through a common Bus.
• ProgramCounter(PC)-This register keeps track of the
  program flow. Its count is incremented after every fetch of
  Op Code or Operand from the Program Memory.
• StackPointer(SP)-This is an up down counter which holds
  the address of the top of the Stack. Its count is
  incremented or decremented after every Push or Pop
  operation of the Stack.
• InstructionRegister(IR)- The OpCode fetched from the
  program memory is loaded here, and its output is fed to
  the Instruction Decoder for generating the Control Signals.
• TemporaryRegisters-These registers are accessible only to
  the system,and cannot be accessed by the user.
Arithmetic & Logic Unit
• Does the calculations
• Everything else in the computer is there
  to service this unit
• Handles integers
• May handle floating point (real) numbers
• May be separate FPU (maths co-
  processor)
• May be on chip separate FPU (486DX +)
ALU Inputs and Outputs
Integer Representation
• Only have 0 & 1 to represent everything
• Positive numbers stored in binary
    —e.g. 41=00101001
•   No minus sign
•   No period
•   Sign-Magnitude
•   Two’s compliment
Sign-Magnitude
•   Left most bit is sign bit (MSB)
•   0 means positive
•   1 means negative
•   +18 = 00010010
•    -18 = 10010010
•   Problems
    —Need to consider both sign and magnitude in
     arithmetic
    —Two representations of zero (+0 and -0)
Two’s Compliment
•   +3   =   00000011
•   +2   =   00000010
•   +1   =   00000001
•   +0   =   00000000
•   -1   =   11111111
•   -2   =   11111110
•   -3   =   11111101
Benefits
• One representation of zero
• Arithmetic works easily (see later)
• Negating is fairly easy
  —3 = 00000011
  —Boolean complement gives    11111100
  —Add 1 to LSB                11111101
Geometric Depiction of Twos
Complement Integers
Negation Special Case 1
•  0=             00000000
• Bitwise not     11111111
• Add 1 to LSB           +1
• Result        1 00000000
• There is carry out of MSB which is ignored
  , so:
• -0=0
Negation Special Case 2
•   -128 =        10000000
•   bitwise not   01111111
•   Add 1 to LSB         +1
•   Result        10000000
•   So:
•   -(-128) = -128 X
•   Monitor MSB (sign bit)
•   It should change during negation
Range of Numbers
• 8 bit 2s compliment
  —+127 = 01111111 = 27 -1
  — -128 = 10000000 = -27
• 16 bit 2s compliment
  —+32767 = 011111111 11111111 = 215 - 1
  — -32768 = 100000000 00000000 = -215
Conversion Between Lengths
•   Positive number pack with leading zeros
•   +18 =             00010010
•   +18 = 00000000 00010010
•   Negative numbers pack with leading ones
•   -18 =            10010010
•   -18 = 11111111 10010010
•   i.e. pack with MSB (sign bit)
Addition and Subtraction
• Normal binary addition
• Monitor sign bit for overflow

• Take twos compliment of subtrahend and
  add to minuend
  —i.e. a - b = a + (-b)


• So we only need addition and complement
  circuits
• If the two numbers are added and they
  are both positive or both negative
  number, then overflow occurs if the result
  has the opposite sign.
Hardware for Addition and Subtraction
Multiplication
•   Complex
•   Work out partial product for each digit
•   Take care with place value (column)
•   Add partial products
Multiplication Example
•     1011 Multiplicand (11 dec)
•   x 1101 Multiplier     (13 dec)
•     1011 Partial products
•   0000    Note: if multiplier bit is 1 copy
• 1011       multiplicand (place value)
• 1011       otherwise zero
• 10001111 Product (143 dec)
• Note: need double length result
Unsigned Binary Multiplication
Execution of Example
Flowchart for Unsigned Binary
Multiplication
Multiplying Negative Numbers
• This does not work!
• Solution 1
  —Convert to positive if required
  —Multiply as above
  —If signs were different, negate answer
• Solution 2
  —Booth’s algorithm
Booth’s Algorithm
Example of Booth’s Algorithm
Division
• More complex than multiplication
• Negative numbers are really bad!
• Based on long division
Division of Unsigned Binary Integers


                 00001101     Quotient
   Divisor   1011 10010011    Dividend
                   1011
                  001110
   Partial          1011
   Remainders
                    001111
                      1011
                        100   Remainder
Flowchart for Unsigned Binary Division
Real Numbers
• Numbers with fractions
• Could be done in pure binary
  —1001.1010 = 24 + 20 +2-1 + 2-3 =9.625
• Where is the binary point?
• Fixed?
  —Very limited
• Moving?
  —How do you show where it is?
Floating Point




• +/- .significand x 2exponent
• Misnomer
• Point is actually fixed between sign bit and body
  of mantissa
• Exponent indicates place value (point position)
Floating Point Examples
Signs for Floating Point
• Mantissa is stored in 2s compliment
• Exponent is in excess or biased notation
  —e.g. Excess (bias) 128 means
  —8 bit exponent field
  —Pure value range 0-255
  —Subtract 128 to get correct value
  —Range -128 to +127
Normalization
• FP numbers are usually normalized
• i.e. exponent is adjusted so that leading
  bit (MSB) of mantissa is 1
• Since it is always 1 there is no need to
  store it
• (c.f. Scientific notation where numbers
  are normalized to give a single digit
  before the decimal point
• e.g. 3.123 x 103)
FP Ranges
• For a 32 bit number
  —8 bit exponent
  —+/- 2256 1.5 x 1077
• Accuracy
  —The effect of changing lsb of mantissa
  —23 bit mantissa 2-23 1.2 x 10-7
  —About 6 decimal places
Expressible Numbers
IEEE 754
•   Standard for floating point storage
•   32 and 64 bit standards
•   8 and 11 bit exponent respectively
•   Extended formats (both mantissa and
    exponent) for intermediate results
IEEE 754 Formats
• 1. Convert the decimal number to binary.
• 2. Write the binary number in scientific notation using 20
• 3. Normalise the number by moving the binary point and
  changing the exponent.
• 4. Write f by taking the fractional part of the normalised
  number and adding trailing zeroes to get 23 bits.
• 5. Determine sign bit.
• 6. Add 127 to the exponent (from step 3) to get e.
• 7. Convert e to an 8 bit binary number (add leading
• zeroes if needed).
• 8. Write in IEEE format by concatenating s, e, and f.
•   (24.5)10
•   11000.1
•   Write in scientific notation
•   11000.1 x 20
•   Normalise the number by moving the binary
    point and changing the exponent
•   1.10001 x 24
•   100 0100 0000 0000 0000 0000
•   Sign bit = 0
•   Add 127 to get e
•   e=127+4=131
•   Convert 131 to binary
•   10000011
•   0 1000 0011 100 0100 0000 0000 0000 0000
• 1. Regroup the binary digits into groups of 1, 8,
  and 23 digits.
• 2. Convert e to a decimal number.
• 3. Subtract 127 to get the exponent .
• 4. Delete the trailing zeroes from f and write 1.f
  x 2exponent where the exponent is the value from
  step 3 and f is the original f with the trailing
  zeroes removed.
• 5. Un-normalise the number by moving the
  binary point until the exponent is 0.
• 6. Drop the 20. It is no longer needed.
• 7. Convert the binary number to decimal.
• 8. If s is 1, put a minus sign in front of the
  decimal number.
•   1100 0001 1100 0100 0000 0000 0000 0000
•   1 1000 0011 100 0100 0000 0000 0000 0000
•   Convert e to decimal
•   1000 0011 = 131
•   Subtract 127 to get true exponent
•   131-127=4
• Delete the trailing zeroes from f and write
  1.f * 2exponent.
• 100 0100 0000 0000 0000 0000
• 10001
• 1.10001 x 24
• Un-normalise the number by moving and
  binary point until the exponent is 0.
• 1.10001 x 24 = 11000.1 x 20
• 11000.1
• 24.5
• s=1
• Answer is -24.5
Counit2
Counit2

More Related Content

What's hot

Integer Representation
Integer RepresentationInteger Representation
Integer Representation
gavhays
 

What's hot (19)

Number systems r002
Number systems  r002Number systems  r002
Number systems r002
 
06 floating point
06 floating point06 floating point
06 floating point
 
Code conversion r006
Code conversion r006Code conversion r006
Code conversion r006
 
Number system
Number systemNumber system
Number system
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
Digital fundamendals r001a
Digital fundamendals r001aDigital fundamendals r001a
Digital fundamendals r001a
 
Quick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationQuick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representation
 
Number system
Number systemNumber system
Number system
 
Binary coded decimal r004
Binary coded decimal   r004Binary coded decimal   r004
Binary coded decimal r004
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
 
Binaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesBinaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemes
 
Floating point representation
Floating point representationFloating point representation
Floating point representation
 
Number system utm notes
Number system utm notesNumber system utm notes
Number system utm notes
 
Combinational circuits r011
Combinational circuits   r011Combinational circuits   r011
Combinational circuits r011
 
Number System
Number SystemNumber System
Number System
 
Codes r005
Codes  r005Codes  r005
Codes r005
 
Integer Representation
Integer RepresentationInteger Representation
Integer Representation
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbers
 
Binary arithmetic
Binary arithmeticBinary arithmetic
Binary arithmetic
 

Similar to Counit2

3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt
RavikumarR77
 

Similar to Counit2 (20)

09 arithmetic 2
09 arithmetic 209 arithmetic 2
09 arithmetic 2
 
arithmetic
arithmeticarithmetic
arithmetic
 
CA UNIT II.pptx
CA UNIT II.pptxCA UNIT II.pptx
CA UNIT II.pptx
 
Unit-1 Digital Design and Binary Numbers:
Unit-1 Digital Design and Binary Numbers:Unit-1 Digital Design and Binary Numbers:
Unit-1 Digital Design and Binary Numbers:
 
BOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etc
BOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etcBOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etc
BOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etc
 
Number Systems.ppt
Number Systems.pptNumber Systems.ppt
Number Systems.ppt
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
Digital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdfDigital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdf
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
CA Unit ii
CA Unit iiCA Unit ii
CA Unit ii
 
Chapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdfChapter 2_Number system (EEEg4302).pdf
Chapter 2_Number system (EEEg4302).pdf
 
Module 2_Data representations.pdf
Module 2_Data representations.pdfModule 2_Data representations.pdf
Module 2_Data representations.pdf
 
Arithmetic unit.ppt
Arithmetic unit.pptArithmetic unit.ppt
Arithmetic unit.ppt
 
ARITHMETIC FOR COMPUTERS
ARITHMETIC FOR COMPUTERS	  ARITHMETIC FOR COMPUTERS
ARITHMETIC FOR COMPUTERS
 
digitalelectronics.ppt
digitalelectronics.pptdigitalelectronics.ppt
digitalelectronics.ppt
 
Floating_point_representation.pdf
Floating_point_representation.pdfFloating_point_representation.pdf
Floating_point_representation.pdf
 
3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt
 
3810-08.ppt
3810-08.ppt3810-08.ppt
3810-08.ppt
 
Representation Of Numbers and Characters
Representation Of Numbers and CharactersRepresentation Of Numbers and Characters
Representation Of Numbers and Characters
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Counit2

  • 2. von Neumann/Turing • Stored Program concept • Main memory storing programs and data • ALU operating on binary data • Control unit interpreting instructions from memory and executing • Input and output equipment operated by control unit • Princeton Institute for Advanced Studies —IAS • Completed 1952
  • 3. Structure of von Neumann machine
  • 4. • Structure of IAS – detail
  • 5. • MemoryAddressRegister(MAR)-This register holds the address of the memory location to be accessed. The desired address is loaded into MAR through a common Bus. • ProgramCounter(PC)-This register keeps track of the program flow. Its count is incremented after every fetch of Op Code or Operand from the Program Memory. • StackPointer(SP)-This is an up down counter which holds the address of the top of the Stack. Its count is incremented or decremented after every Push or Pop operation of the Stack. • InstructionRegister(IR)- The OpCode fetched from the program memory is loaded here, and its output is fed to the Instruction Decoder for generating the Control Signals. • TemporaryRegisters-These registers are accessible only to the system,and cannot be accessed by the user.
  • 6.
  • 7.
  • 8. Arithmetic & Logic Unit • Does the calculations • Everything else in the computer is there to service this unit • Handles integers • May handle floating point (real) numbers • May be separate FPU (maths co- processor) • May be on chip separate FPU (486DX +)
  • 9.
  • 10. ALU Inputs and Outputs
  • 11. Integer Representation • Only have 0 & 1 to represent everything • Positive numbers stored in binary —e.g. 41=00101001 • No minus sign • No period • Sign-Magnitude • Two’s compliment
  • 12. Sign-Magnitude • Left most bit is sign bit (MSB) • 0 means positive • 1 means negative • +18 = 00010010 • -18 = 10010010 • Problems —Need to consider both sign and magnitude in arithmetic —Two representations of zero (+0 and -0)
  • 13. Two’s Compliment • +3 = 00000011 • +2 = 00000010 • +1 = 00000001 • +0 = 00000000 • -1 = 11111111 • -2 = 11111110 • -3 = 11111101
  • 14. Benefits • One representation of zero • Arithmetic works easily (see later) • Negating is fairly easy —3 = 00000011 —Boolean complement gives 11111100 —Add 1 to LSB 11111101
  • 15. Geometric Depiction of Twos Complement Integers
  • 16. Negation Special Case 1 • 0= 00000000 • Bitwise not 11111111 • Add 1 to LSB +1 • Result 1 00000000 • There is carry out of MSB which is ignored , so: • -0=0
  • 17. Negation Special Case 2 • -128 = 10000000 • bitwise not 01111111 • Add 1 to LSB +1 • Result 10000000 • So: • -(-128) = -128 X • Monitor MSB (sign bit) • It should change during negation
  • 18. Range of Numbers • 8 bit 2s compliment —+127 = 01111111 = 27 -1 — -128 = 10000000 = -27 • 16 bit 2s compliment —+32767 = 011111111 11111111 = 215 - 1 — -32768 = 100000000 00000000 = -215
  • 19. Conversion Between Lengths • Positive number pack with leading zeros • +18 = 00010010 • +18 = 00000000 00010010 • Negative numbers pack with leading ones • -18 = 10010010 • -18 = 11111111 10010010 • i.e. pack with MSB (sign bit)
  • 20. Addition and Subtraction • Normal binary addition • Monitor sign bit for overflow • Take twos compliment of subtrahend and add to minuend —i.e. a - b = a + (-b) • So we only need addition and complement circuits
  • 21.
  • 22.
  • 23. • If the two numbers are added and they are both positive or both negative number, then overflow occurs if the result has the opposite sign.
  • 24. Hardware for Addition and Subtraction
  • 25. Multiplication • Complex • Work out partial product for each digit • Take care with place value (column) • Add partial products
  • 26. Multiplication Example • 1011 Multiplicand (11 dec) • x 1101 Multiplier (13 dec) • 1011 Partial products • 0000 Note: if multiplier bit is 1 copy • 1011 multiplicand (place value) • 1011 otherwise zero • 10001111 Product (143 dec) • Note: need double length result
  • 29. Flowchart for Unsigned Binary Multiplication
  • 30. Multiplying Negative Numbers • This does not work! • Solution 1 —Convert to positive if required —Multiply as above —If signs were different, negate answer • Solution 2 —Booth’s algorithm
  • 32. Example of Booth’s Algorithm
  • 33. Division • More complex than multiplication • Negative numbers are really bad! • Based on long division
  • 34.
  • 35. Division of Unsigned Binary Integers 00001101 Quotient Divisor 1011 10010011 Dividend 1011 001110 Partial 1011 Remainders 001111 1011 100 Remainder
  • 36. Flowchart for Unsigned Binary Division
  • 37.
  • 38. Real Numbers • Numbers with fractions • Could be done in pure binary —1001.1010 = 24 + 20 +2-1 + 2-3 =9.625 • Where is the binary point? • Fixed? —Very limited • Moving? —How do you show where it is?
  • 39. Floating Point • +/- .significand x 2exponent • Misnomer • Point is actually fixed between sign bit and body of mantissa • Exponent indicates place value (point position)
  • 41. Signs for Floating Point • Mantissa is stored in 2s compliment • Exponent is in excess or biased notation —e.g. Excess (bias) 128 means —8 bit exponent field —Pure value range 0-255 —Subtract 128 to get correct value —Range -128 to +127
  • 42. Normalization • FP numbers are usually normalized • i.e. exponent is adjusted so that leading bit (MSB) of mantissa is 1 • Since it is always 1 there is no need to store it • (c.f. Scientific notation where numbers are normalized to give a single digit before the decimal point • e.g. 3.123 x 103)
  • 43. FP Ranges • For a 32 bit number —8 bit exponent —+/- 2256 1.5 x 1077 • Accuracy —The effect of changing lsb of mantissa —23 bit mantissa 2-23 1.2 x 10-7 —About 6 decimal places
  • 45. IEEE 754 • Standard for floating point storage • 32 and 64 bit standards • 8 and 11 bit exponent respectively • Extended formats (both mantissa and exponent) for intermediate results
  • 47. • 1. Convert the decimal number to binary. • 2. Write the binary number in scientific notation using 20 • 3. Normalise the number by moving the binary point and changing the exponent. • 4. Write f by taking the fractional part of the normalised number and adding trailing zeroes to get 23 bits. • 5. Determine sign bit. • 6. Add 127 to the exponent (from step 3) to get e. • 7. Convert e to an 8 bit binary number (add leading • zeroes if needed). • 8. Write in IEEE format by concatenating s, e, and f.
  • 48. (24.5)10 • 11000.1 • Write in scientific notation • 11000.1 x 20 • Normalise the number by moving the binary point and changing the exponent • 1.10001 x 24 • 100 0100 0000 0000 0000 0000 • Sign bit = 0 • Add 127 to get e • e=127+4=131 • Convert 131 to binary • 10000011 • 0 1000 0011 100 0100 0000 0000 0000 0000
  • 49. • 1. Regroup the binary digits into groups of 1, 8, and 23 digits. • 2. Convert e to a decimal number. • 3. Subtract 127 to get the exponent . • 4. Delete the trailing zeroes from f and write 1.f x 2exponent where the exponent is the value from step 3 and f is the original f with the trailing zeroes removed. • 5. Un-normalise the number by moving the binary point until the exponent is 0. • 6. Drop the 20. It is no longer needed. • 7. Convert the binary number to decimal. • 8. If s is 1, put a minus sign in front of the decimal number.
  • 50. 1100 0001 1100 0100 0000 0000 0000 0000 • 1 1000 0011 100 0100 0000 0000 0000 0000 • Convert e to decimal • 1000 0011 = 131 • Subtract 127 to get true exponent • 131-127=4 • Delete the trailing zeroes from f and write 1.f * 2exponent. • 100 0100 0000 0000 0000 0000 • 10001 • 1.10001 x 24
  • 51. • Un-normalise the number by moving and binary point until the exponent is 0. • 1.10001 x 24 = 11000.1 x 20 • 11000.1 • 24.5 • s=1 • Answer is -24.5