SlideShare a Scribd company logo
1 of 15
FLOATING POINT REPRESENTATION
AND ARITHMETIC
Presentation Topic
B. Sc CS (H)I Year Computer Organization and Architecture
SIR CHHOTU RAM ENGG. INSTITUTE & TECH. CCS UNIV. CAMPUS, MEERUT
INTRODUCTION
•Objective: To understand how to represent floating point numbers
in the computer and how to perform arithmetic with them.
•Approximate arithmetic
–Finite Range
–Limited Precision
•Topics
–IEEE format for single and double precision floating point numbers
–Floating point addition
DISTRIBUTION OF FLOATING POINT NUMBERS
s
•3 bit mantissa
•exponent {-1,0,1}
e = -1 e = 0 e = 1
1.00 X 2^(-1) = 1/2 1.00 X 2^0 = 1 1.00 X 2^1 = 2
1.01 X 2^(-1) = 5/8 1.01 X 2^0 = 5/4 1.01 X 2^1 = 5/2
1.10 X 2^(-1) = 3/4 1.10 X 2^0 = 3/2 1.10 X 2^1= 3
1.11 X 2^(-1) = 7/8 1.11 X 2^0 = 7/4 1.11 X 2^1 = 7/2
0 1 2 3
FLOATING POINT
• An IEEE floating point representation consists of
–A Sign Bit (no surprise)
–An Exponent (“times 2 to the what?”)
–Mantissa (“Significand”), which is assumed to be 1.xxxxx
(thus, one bit of the mantissa is implied as 1)
–This is called a normalized representation
• So a mantissa = 0 really is interpreted to be 1.0, and a
mantissa of all 1111 is interpreted to be 1.1111
• Special cases are used to represent denormalized mantissas
(true mantissa = 0), NaN, etc., as will be discussed.
FLOATING POINT STANDARD
• Defined by IEEE Std 754-1985
• Developed in response to divergence of representations
–Portability issues for scientific code
• Now almost universally adopted
• Two representations
–Single precision (32-bit)
–Double precision (64-bit)
S
s
6
IEEE Floating-Point Format
• S: sign bit (0  non-negative, 1  negative)
• Normalize significand: 1.0 ≤ |significand| < 2.0
– Always has a leading pre-binary-point 1 bit, so no need to represent it explicitly
(hidden bit)
– Significand is Fraction with the “1.” restored
• Exponent: excess representation: actual exponent + Bias
– Ensures exponent is unsigned
– Single: Bias = 127; Double: Bias = 1203
S Exponent Fraction
single: 8 bits
double: 11 bits
single: 23 bits
double: 52 bits
Bias)
(Exponent
S
2
Fraction)
(1
1)
(
x 





BASICTECHNIQUE
• Represent the decimal in the form +/- 1.xxxb x 2y
• And “fill in the fields”
–Remember biased exponent and implicit “1.” mantissa!
• Examples:
–0.0: 0 00000000 00000000000000000000000
–1.0 (1.0 x 2^0): 0 01111111 00000000000000000000000
–0.5 (0.1 binary = 1.0 x 2^-1): 0 01111110
00000000000000000000000
–0.75 (0.11 binary = 1.1 x 2^-1): 0 01111110
10000000000000000000000
–3.0 (11 binary = 1.1*2^1): 0 10000000 10000000000000000000000
–-0.375 (-0.011 binary = -1.1*2^-2): 1 01111101
FLOATING-POINT EXAMPLE
• Represent –0.75
– –0.75 = (–1)1 × 1.12 × 2–1
– S = 1
– Fraction = 1000…002
– Exponent = –1 + Bias
• Single: –1 + 127 = 126 = 011111102
• Double: –1 + 1023 = 1022 = 011111111102
• Single: 1011111101000…00
• Double: 1011111111101000…00
FLOATING-POINT EXAMPLE
• What number is represented by the single-
precision float
11000000101000…00
– S = 1
– Fraction = 01000…002
– Fxponent = 100000012 = 129
• x = (–1)1 × (1 + 012) × 2(129 – 127)
= (–1) × 1.25 × 22
= –5.0
A
s
Representation of Floating Point Numbers
•IEEE 754 double precision
31 30 20 19 0
Sign Biased exponent Normalized Mantissa (implicit 53rd bit)
(-1)s  F  2E-1023
Exponent Mantissa Object Represented
0 0 0
0 non-zero denormalized
1-2046 anything FP number
2047 0 pm infinity
2047 non-zero NaN
FLOATING POINT ARITHMETIC
• fl(x) = nearest floating point number to x
• Relative error (precision = s digits)
–|x - fl(x)|/|x| 1/2 1-s for = 2, 2-s
• Arithmetic
–x y = fl(x+y) = (x + y)(1 + ) for < u
–x y = fl(x y)(1 + ) for < u
ULP—Unit in the Last Place is the smallest possible increment or decrement
that can be made using the machine's FP arithmetic.
FLOATING-POINT PRECISION
• Relative precision
– all fraction bits are significant
– Single: approx 2–23
• Equivalent to 23 × log102 ≈ 23 × 0.3 ≈ 6 decimal digits of
precision
– Double: approx 2–52
• Equivalent to 52 × log102 ≈ 52 × 0.3 ≈ 16 decimal digits of
precision
IS FP ADDITION ASSOCIATIVE?
• Associativity law for addition: a + (b + c) = (a + b) + c
• Let a = – 2.7 x 1023, b = 2.7 x 1023, and c = 1.0
• a + (b + c) = – 2.7 x 1023 + ( 2.7 x 1023 + 1.0 ) = – 2.7 x 1023 + 2.7 x
1023 = 0.0
• (a + b) + c = ( – 2.7 x 1023 + 2.7 x 1023 ) + 1.0 = 0.0 + 1.0 = 1.0
• Beware – Floating Point addition not associative!
• The result is approximate…
• Why the smaller number disappeared?
FLOATING POINT -ADDITION
• Consider a 4-digit decimal example
– 9.999 × 101 + 1.610 × 10–1
• 1. Align decimal points
– Shift number with smaller exponent
– 9.999 × 101 + 0.016 × 101
• 2. Add significands
– 9.999 × 101 + 0.016 × 101 = 10.015 × 101
• 3. Normalize result & check for over/underflow
– 1.0015 × 102
• 4. Round and renormalize if necessary
– 1.002 × 102
FLOATING-POINT ADDITION
• Now consider a 4-digit binary example
– 1.0002 × 2–1 + –1.1102 × 2–2 (0.5 + –0.4375)
• 1. Align binary points
– Shift number with smaller exponent
– 1.0002 × 2–1 + –0.1112 × 2–1
• 2. Add significands
– 1.0002 × 2–1 + –0.1112 × 2–1 = 0.0012 × 2–1
• 3. Normalize result & check for over/underflow
– 1.0002 × 2–4, with no over/underflow
• 4. Round and renormalize if necessary
– 1.0002 × 2–4 (no change) = 0.0625

More Related Content

What's hot

What's hot (20)

DIGITAL ELECTRONICS- Number System
DIGITAL ELECTRONICS- Number SystemDIGITAL ELECTRONICS- Number System
DIGITAL ELECTRONICS- Number System
 
Dda line-algorithm
Dda line-algorithmDda line-algorithm
Dda line-algorithm
 
Floating point Binary Represenataion
Floating point Binary RepresenataionFloating point Binary Represenataion
Floating point Binary Represenataion
 
Numbersystemcont
NumbersystemcontNumbersystemcont
Numbersystemcont
 
Data representation
Data representationData representation
Data representation
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
 
Iwb Training
Iwb TrainingIwb Training
Iwb Training
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing Algorithm
 
Number System & Data Representation
Number System & Data RepresentationNumber System & Data Representation
Number System & Data Representation
 
Digital logic design part1
Digital logic design part1Digital logic design part1
Digital logic design part1
 
DESIGN OF COMBINATIONAL LOGIC
DESIGN OF COMBINATIONAL LOGICDESIGN OF COMBINATIONAL LOGIC
DESIGN OF COMBINATIONAL LOGIC
 
Understand data representation on CPU 1
Understand data representation on CPU 1Understand data representation on CPU 1
Understand data representation on CPU 1
 
ALL ABOUT NUMBER SYSTEMS
ALL ABOUT NUMBER SYSTEMSALL ABOUT NUMBER SYSTEMS
ALL ABOUT NUMBER SYSTEMS
 
Chapter 01 Basic Principles of Digital Systems
Chapter 01 Basic Principles of Digital SystemsChapter 01 Basic Principles of Digital Systems
Chapter 01 Basic Principles of Digital Systems
 
Introducing to number system
Introducing to number systemIntroducing to number system
Introducing to number system
 
Linear equation 2 2
Linear equation 2 2Linear equation 2 2
Linear equation 2 2
 
Daa unit iv - problems
Daa   unit  iv - problemsDaa   unit  iv - problems
Daa unit iv - problems
 
digital logic design Chapter 2 boolean_algebra_&_logic_gates
digital logic design Chapter 2 boolean_algebra_&_logic_gatesdigital logic design Chapter 2 boolean_algebra_&_logic_gates
digital logic design Chapter 2 boolean_algebra_&_logic_gates
 
Mth 4108-1 a
Mth 4108-1 aMth 4108-1 a
Mth 4108-1 a
 
Metnum (interpolasi)
Metnum (interpolasi)Metnum (interpolasi)
Metnum (interpolasi)
 

Similar to Floating point representation and arithmetic

Aviraj --floating point representation and arithmetic.pptx
Aviraj --floating point representation and arithmetic.pptxAviraj --floating point representation and arithmetic.pptx
Aviraj --floating point representation and arithmetic.pptxIronmanhmarvel
 
B.sc cs-ii-u-1.8 digital logic circuits, digital component floting and fixed ...
B.sc cs-ii-u-1.8 digital logic circuits, digital component floting and fixed ...B.sc cs-ii-u-1.8 digital logic circuits, digital component floting and fixed ...
B.sc cs-ii-u-1.8 digital logic circuits, digital component floting and fixed ...Rai University
 
Bca 2nd sem-u-1.8 digital logic circuits, digital component floting and fixed...
Bca 2nd sem-u-1.8 digital logic circuits, digital component floting and fixed...Bca 2nd sem-u-1.8 digital logic circuits, digital component floting and fixed...
Bca 2nd sem-u-1.8 digital logic circuits, digital component floting and fixed...Rai University
 
digital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed pointdigital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed pointRai University
 
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 etcAbhishek Rajpoot
 
L12-FloatingPoint.ppt
L12-FloatingPoint.pptL12-FloatingPoint.ppt
L12-FloatingPoint.pptDevcond
 
IEEE 754 Standards For Floating Point Representation.pdf
IEEE 754 Standards For Floating Point   Representation.pdfIEEE 754 Standards For Floating Point   Representation.pdf
IEEE 754 Standards For Floating Point Representation.pdfkkumaraditya301
 
number system: Floating Point representation.ppt
number system: Floating Point representation.pptnumber system: Floating Point representation.ppt
number system: Floating Point representation.pptNARENDRAKUMARCHAURAS1
 
Number system and codes
Number system and codesNumber system and codes
Number system and codesAbhiraj Bohra
 
IEEE floating point representation
 IEEE floating point representation IEEE floating point representation
IEEE floating point representationMaskurAlShalSabil
 
03_NumberSystems.pdf
03_NumberSystems.pdf03_NumberSystems.pdf
03_NumberSystems.pdfvijayapraba1
 
Floating Point Represenataion.pptx
Floating Point Represenataion.pptxFloating Point Represenataion.pptx
Floating Point Represenataion.pptxKarthikeyanC53
 
Basic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and programBasic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and programJyotiprakashMishra18
 

Similar to Floating point representation and arithmetic (20)

Aviraj --floating point representation and arithmetic.pptx
Aviraj --floating point representation and arithmetic.pptxAviraj --floating point representation and arithmetic.pptx
Aviraj --floating point representation and arithmetic.pptx
 
B.sc cs-ii-u-1.8 digital logic circuits, digital component floting and fixed ...
B.sc cs-ii-u-1.8 digital logic circuits, digital component floting and fixed ...B.sc cs-ii-u-1.8 digital logic circuits, digital component floting and fixed ...
B.sc cs-ii-u-1.8 digital logic circuits, digital component floting and fixed ...
 
Bca 2nd sem-u-1.8 digital logic circuits, digital component floting and fixed...
Bca 2nd sem-u-1.8 digital logic circuits, digital component floting and fixed...Bca 2nd sem-u-1.8 digital logic circuits, digital component floting and fixed...
Bca 2nd sem-u-1.8 digital logic circuits, digital component floting and fixed...
 
digital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed pointdigital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed point
 
Class10
Class10Class10
Class10
 
Class10
Class10Class10
Class10
 
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
 
06 floating point
06 floating point06 floating point
06 floating point
 
L12-FloatingPoint.ppt
L12-FloatingPoint.pptL12-FloatingPoint.ppt
L12-FloatingPoint.ppt
 
IEEE 754 Standards For Floating Point Representation.pdf
IEEE 754 Standards For Floating Point   Representation.pdfIEEE 754 Standards For Floating Point   Representation.pdf
IEEE 754 Standards For Floating Point Representation.pdf
 
number system: Floating Point representation.ppt
number system: Floating Point representation.pptnumber system: Floating Point representation.ppt
number system: Floating Point representation.ppt
 
Chpater 6
Chpater 6Chpater 6
Chpater 6
 
Floating Point Numbers
Floating Point NumbersFloating Point Numbers
Floating Point Numbers
 
Number system and codes
Number system and codesNumber system and codes
Number system and codes
 
IEEE floating point representation
 IEEE floating point representation IEEE floating point representation
IEEE floating point representation
 
03_NumberSystems.pdf
03_NumberSystems.pdf03_NumberSystems.pdf
03_NumberSystems.pdf
 
Counit2
Counit2Counit2
Counit2
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Floating Point Represenataion.pptx
Floating Point Represenataion.pptxFloating Point Represenataion.pptx
Floating Point Represenataion.pptx
 
Basic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and programBasic arithmetic, instruction execution and program
Basic arithmetic, instruction execution and program
 

Recently uploaded

VIP Kolkata Call Girl Kalighat 👉 8250192130 Available With Room
VIP Kolkata Call Girl Kalighat 👉 8250192130  Available With RoomVIP Kolkata Call Girl Kalighat 👉 8250192130  Available With Room
VIP Kolkata Call Girl Kalighat 👉 8250192130 Available With Roomdivyansh0kumar0
 
The Most Attractive Pune Call Girls Shirwal 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Shirwal 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Shirwal 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Shirwal 8250192130 Will You Miss This Cha...ranjana rawat
 
Call Girls Mumbai Gayatri 8617697112 Independent Escort Service Mumbai
Call Girls Mumbai Gayatri 8617697112 Independent Escort Service MumbaiCall Girls Mumbai Gayatri 8617697112 Independent Escort Service Mumbai
Call Girls Mumbai Gayatri 8617697112 Independent Escort Service MumbaiCall girls in Ahmedabad High profile
 
webinaire-green-mirror-episode-2-Smart contracts and virtual purchase agreeme...
webinaire-green-mirror-episode-2-Smart contracts and virtual purchase agreeme...webinaire-green-mirror-episode-2-Smart contracts and virtual purchase agreeme...
webinaire-green-mirror-episode-2-Smart contracts and virtual purchase agreeme...Cluster TWEED
 
9873940964 High Profile Call Girls Delhi |Defence Colony ( MAYA CHOPRA ) DE...
9873940964 High Profile  Call Girls  Delhi |Defence Colony ( MAYA CHOPRA ) DE...9873940964 High Profile  Call Girls  Delhi |Defence Colony ( MAYA CHOPRA ) DE...
9873940964 High Profile Call Girls Delhi |Defence Colony ( MAYA CHOPRA ) DE...Delhi Escorts
 
(RIYA) Kalyani Nagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(RIYA) Kalyani Nagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(RIYA) Kalyani Nagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(RIYA) Kalyani Nagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Russian Call Girls Nashik Anjali 7001305949 Independent Escort Service Nashik
Russian Call Girls Nashik Anjali 7001305949 Independent Escort Service NashikRussian Call Girls Nashik Anjali 7001305949 Independent Escort Service Nashik
Russian Call Girls Nashik Anjali 7001305949 Independent Escort Service Nashikranjana rawat
 
BOOK Call Girls in (Dwarka) CALL | 8377087607 Delhi Escorts Services
BOOK Call Girls in (Dwarka) CALL | 8377087607 Delhi Escorts ServicesBOOK Call Girls in (Dwarka) CALL | 8377087607 Delhi Escorts Services
BOOK Call Girls in (Dwarka) CALL | 8377087607 Delhi Escorts Servicesdollysharma2066
 
Call Girls Service Nagpur Aditi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Aditi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Aditi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Aditi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Sustainable Clothing Strategies and Challenges
Sustainable Clothing Strategies and ChallengesSustainable Clothing Strategies and Challenges
Sustainable Clothing Strategies and ChallengesDr. Salem Baidas
 
(AISHA) Wagholi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(AISHA) Wagholi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(AISHA) Wagholi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(AISHA) Wagholi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
VIP Call Girls Service Chaitanyapuri Hyderabad Call +91-8250192130
VIP Call Girls Service Chaitanyapuri Hyderabad Call +91-8250192130VIP Call Girls Service Chaitanyapuri Hyderabad Call +91-8250192130
VIP Call Girls Service Chaitanyapuri Hyderabad Call +91-8250192130Suhani Kapoor
 
(ZARA) Call Girls Talegaon Dabhade ( 7001035870 ) HI-Fi Pune Escorts Service
(ZARA) Call Girls Talegaon Dabhade ( 7001035870 ) HI-Fi Pune Escorts Service(ZARA) Call Girls Talegaon Dabhade ( 7001035870 ) HI-Fi Pune Escorts Service
(ZARA) Call Girls Talegaon Dabhade ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
(NANDITA) Hadapsar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune ...
(NANDITA) Hadapsar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune ...(NANDITA) Hadapsar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune ...
(NANDITA) Hadapsar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune ...ranjana rawat
 
Horizon Net Zero Dawn – keynote slides by Ben Abraham
Horizon Net Zero Dawn – keynote slides by Ben AbrahamHorizon Net Zero Dawn – keynote slides by Ben Abraham
Horizon Net Zero Dawn – keynote slides by Ben Abrahamssuserbb03ff
 
VIP Call Girls Ramanthapur ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Ramanthapur ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...VIP Call Girls Ramanthapur ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Ramanthapur ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...Suhani Kapoor
 

Recently uploaded (20)

VIP Kolkata Call Girl Kalighat 👉 8250192130 Available With Room
VIP Kolkata Call Girl Kalighat 👉 8250192130  Available With RoomVIP Kolkata Call Girl Kalighat 👉 8250192130  Available With Room
VIP Kolkata Call Girl Kalighat 👉 8250192130 Available With Room
 
The Most Attractive Pune Call Girls Shirwal 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Shirwal 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Shirwal 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Shirwal 8250192130 Will You Miss This Cha...
 
Call Girls In Pratap Nagar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCe
Call Girls In Pratap Nagar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCeCall Girls In Pratap Nagar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCe
Call Girls In Pratap Nagar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCe
 
Model Call Girl in Rajiv Chowk Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Rajiv Chowk Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Rajiv Chowk Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Rajiv Chowk Delhi reach out to us at 🔝9953056974🔝
 
Call Girls Mumbai Gayatri 8617697112 Independent Escort Service Mumbai
Call Girls Mumbai Gayatri 8617697112 Independent Escort Service MumbaiCall Girls Mumbai Gayatri 8617697112 Independent Escort Service Mumbai
Call Girls Mumbai Gayatri 8617697112 Independent Escort Service Mumbai
 
webinaire-green-mirror-episode-2-Smart contracts and virtual purchase agreeme...
webinaire-green-mirror-episode-2-Smart contracts and virtual purchase agreeme...webinaire-green-mirror-episode-2-Smart contracts and virtual purchase agreeme...
webinaire-green-mirror-episode-2-Smart contracts and virtual purchase agreeme...
 
Green Banking
Green Banking Green Banking
Green Banking
 
9873940964 High Profile Call Girls Delhi |Defence Colony ( MAYA CHOPRA ) DE...
9873940964 High Profile  Call Girls  Delhi |Defence Colony ( MAYA CHOPRA ) DE...9873940964 High Profile  Call Girls  Delhi |Defence Colony ( MAYA CHOPRA ) DE...
9873940964 High Profile Call Girls Delhi |Defence Colony ( MAYA CHOPRA ) DE...
 
(RIYA) Kalyani Nagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(RIYA) Kalyani Nagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(RIYA) Kalyani Nagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(RIYA) Kalyani Nagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Russian Call Girls Nashik Anjali 7001305949 Independent Escort Service Nashik
Russian Call Girls Nashik Anjali 7001305949 Independent Escort Service NashikRussian Call Girls Nashik Anjali 7001305949 Independent Escort Service Nashik
Russian Call Girls Nashik Anjali 7001305949 Independent Escort Service Nashik
 
BOOK Call Girls in (Dwarka) CALL | 8377087607 Delhi Escorts Services
BOOK Call Girls in (Dwarka) CALL | 8377087607 Delhi Escorts ServicesBOOK Call Girls in (Dwarka) CALL | 8377087607 Delhi Escorts Services
BOOK Call Girls in (Dwarka) CALL | 8377087607 Delhi Escorts Services
 
Call Girls Service Nagpur Aditi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Aditi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Aditi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Aditi Call 7001035870 Meet With Nagpur Escorts
 
Sustainable Clothing Strategies and Challenges
Sustainable Clothing Strategies and ChallengesSustainable Clothing Strategies and Challenges
Sustainable Clothing Strategies and Challenges
 
(AISHA) Wagholi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(AISHA) Wagholi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(AISHA) Wagholi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(AISHA) Wagholi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
VIP Call Girls Service Chaitanyapuri Hyderabad Call +91-8250192130
VIP Call Girls Service Chaitanyapuri Hyderabad Call +91-8250192130VIP Call Girls Service Chaitanyapuri Hyderabad Call +91-8250192130
VIP Call Girls Service Chaitanyapuri Hyderabad Call +91-8250192130
 
(ZARA) Call Girls Talegaon Dabhade ( 7001035870 ) HI-Fi Pune Escorts Service
(ZARA) Call Girls Talegaon Dabhade ( 7001035870 ) HI-Fi Pune Escorts Service(ZARA) Call Girls Talegaon Dabhade ( 7001035870 ) HI-Fi Pune Escorts Service
(ZARA) Call Girls Talegaon Dabhade ( 7001035870 ) HI-Fi Pune Escorts Service
 
(NANDITA) Hadapsar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune ...
(NANDITA) Hadapsar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune ...(NANDITA) Hadapsar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune ...
(NANDITA) Hadapsar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune ...
 
Horizon Net Zero Dawn – keynote slides by Ben Abraham
Horizon Net Zero Dawn – keynote slides by Ben AbrahamHorizon Net Zero Dawn – keynote slides by Ben Abraham
Horizon Net Zero Dawn – keynote slides by Ben Abraham
 
VIP Call Girls Ramanthapur ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Ramanthapur ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...VIP Call Girls Ramanthapur ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Ramanthapur ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
 
Escort Service Call Girls In Shakti Nagar, 99530°56974 Delhi NCR
Escort Service Call Girls In Shakti Nagar, 99530°56974 Delhi NCREscort Service Call Girls In Shakti Nagar, 99530°56974 Delhi NCR
Escort Service Call Girls In Shakti Nagar, 99530°56974 Delhi NCR
 

Floating point representation and arithmetic

  • 1. FLOATING POINT REPRESENTATION AND ARITHMETIC Presentation Topic B. Sc CS (H)I Year Computer Organization and Architecture SIR CHHOTU RAM ENGG. INSTITUTE & TECH. CCS UNIV. CAMPUS, MEERUT
  • 2. INTRODUCTION •Objective: To understand how to represent floating point numbers in the computer and how to perform arithmetic with them. •Approximate arithmetic –Finite Range –Limited Precision •Topics –IEEE format for single and double precision floating point numbers –Floating point addition
  • 3. DISTRIBUTION OF FLOATING POINT NUMBERS s •3 bit mantissa •exponent {-1,0,1} e = -1 e = 0 e = 1 1.00 X 2^(-1) = 1/2 1.00 X 2^0 = 1 1.00 X 2^1 = 2 1.01 X 2^(-1) = 5/8 1.01 X 2^0 = 5/4 1.01 X 2^1 = 5/2 1.10 X 2^(-1) = 3/4 1.10 X 2^0 = 3/2 1.10 X 2^1= 3 1.11 X 2^(-1) = 7/8 1.11 X 2^0 = 7/4 1.11 X 2^1 = 7/2 0 1 2 3
  • 4. FLOATING POINT • An IEEE floating point representation consists of –A Sign Bit (no surprise) –An Exponent (“times 2 to the what?”) –Mantissa (“Significand”), which is assumed to be 1.xxxxx (thus, one bit of the mantissa is implied as 1) –This is called a normalized representation • So a mantissa = 0 really is interpreted to be 1.0, and a mantissa of all 1111 is interpreted to be 1.1111 • Special cases are used to represent denormalized mantissas (true mantissa = 0), NaN, etc., as will be discussed.
  • 5. FLOATING POINT STANDARD • Defined by IEEE Std 754-1985 • Developed in response to divergence of representations –Portability issues for scientific code • Now almost universally adopted • Two representations –Single precision (32-bit) –Double precision (64-bit)
  • 6. S s 6 IEEE Floating-Point Format • S: sign bit (0  non-negative, 1  negative) • Normalize significand: 1.0 ≤ |significand| < 2.0 – Always has a leading pre-binary-point 1 bit, so no need to represent it explicitly (hidden bit) – Significand is Fraction with the “1.” restored • Exponent: excess representation: actual exponent + Bias – Ensures exponent is unsigned – Single: Bias = 127; Double: Bias = 1203 S Exponent Fraction single: 8 bits double: 11 bits single: 23 bits double: 52 bits Bias) (Exponent S 2 Fraction) (1 1) ( x      
  • 7. BASICTECHNIQUE • Represent the decimal in the form +/- 1.xxxb x 2y • And “fill in the fields” –Remember biased exponent and implicit “1.” mantissa! • Examples: –0.0: 0 00000000 00000000000000000000000 –1.0 (1.0 x 2^0): 0 01111111 00000000000000000000000 –0.5 (0.1 binary = 1.0 x 2^-1): 0 01111110 00000000000000000000000 –0.75 (0.11 binary = 1.1 x 2^-1): 0 01111110 10000000000000000000000 –3.0 (11 binary = 1.1*2^1): 0 10000000 10000000000000000000000 –-0.375 (-0.011 binary = -1.1*2^-2): 1 01111101
  • 8. FLOATING-POINT EXAMPLE • Represent –0.75 – –0.75 = (–1)1 × 1.12 × 2–1 – S = 1 – Fraction = 1000…002 – Exponent = –1 + Bias • Single: –1 + 127 = 126 = 011111102 • Double: –1 + 1023 = 1022 = 011111111102 • Single: 1011111101000…00 • Double: 1011111111101000…00
  • 9. FLOATING-POINT EXAMPLE • What number is represented by the single- precision float 11000000101000…00 – S = 1 – Fraction = 01000…002 – Fxponent = 100000012 = 129 • x = (–1)1 × (1 + 012) × 2(129 – 127) = (–1) × 1.25 × 22 = –5.0
  • 10. A s Representation of Floating Point Numbers •IEEE 754 double precision 31 30 20 19 0 Sign Biased exponent Normalized Mantissa (implicit 53rd bit) (-1)s  F  2E-1023 Exponent Mantissa Object Represented 0 0 0 0 non-zero denormalized 1-2046 anything FP number 2047 0 pm infinity 2047 non-zero NaN
  • 11. FLOATING POINT ARITHMETIC • fl(x) = nearest floating point number to x • Relative error (precision = s digits) –|x - fl(x)|/|x| 1/2 1-s for = 2, 2-s • Arithmetic –x y = fl(x+y) = (x + y)(1 + ) for < u –x y = fl(x y)(1 + ) for < u ULP—Unit in the Last Place is the smallest possible increment or decrement that can be made using the machine's FP arithmetic.
  • 12. FLOATING-POINT PRECISION • Relative precision – all fraction bits are significant – Single: approx 2–23 • Equivalent to 23 × log102 ≈ 23 × 0.3 ≈ 6 decimal digits of precision – Double: approx 2–52 • Equivalent to 52 × log102 ≈ 52 × 0.3 ≈ 16 decimal digits of precision
  • 13. IS FP ADDITION ASSOCIATIVE? • Associativity law for addition: a + (b + c) = (a + b) + c • Let a = – 2.7 x 1023, b = 2.7 x 1023, and c = 1.0 • a + (b + c) = – 2.7 x 1023 + ( 2.7 x 1023 + 1.0 ) = – 2.7 x 1023 + 2.7 x 1023 = 0.0 • (a + b) + c = ( – 2.7 x 1023 + 2.7 x 1023 ) + 1.0 = 0.0 + 1.0 = 1.0 • Beware – Floating Point addition not associative! • The result is approximate… • Why the smaller number disappeared?
  • 14. FLOATING POINT -ADDITION • Consider a 4-digit decimal example – 9.999 × 101 + 1.610 × 10–1 • 1. Align decimal points – Shift number with smaller exponent – 9.999 × 101 + 0.016 × 101 • 2. Add significands – 9.999 × 101 + 0.016 × 101 = 10.015 × 101 • 3. Normalize result & check for over/underflow – 1.0015 × 102 • 4. Round and renormalize if necessary – 1.002 × 102
  • 15. FLOATING-POINT ADDITION • Now consider a 4-digit binary example – 1.0002 × 2–1 + –1.1102 × 2–2 (0.5 + –0.4375) • 1. Align binary points – Shift number with smaller exponent – 1.0002 × 2–1 + –0.1112 × 2–1 • 2. Add significands – 1.0002 × 2–1 + –0.1112 × 2–1 = 0.0012 × 2–1 • 3. Normalize result & check for over/underflow – 1.0002 × 2–4, with no over/underflow • 4. Round and renormalize if necessary – 1.0002 × 2–4 (no change) = 0.0625