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

885MTAMount DMU University Bachelor's Diploma in Education
885MTAMount DMU University Bachelor's Diploma in Education885MTAMount DMU University Bachelor's Diploma in Education
885MTAMount DMU University Bachelor's Diploma in Educationz xss
 
AI and Ecology - The H4rmony Project.pptx
AI and Ecology - The H4rmony Project.pptxAI and Ecology - The H4rmony Project.pptx
AI and Ecology - The H4rmony Project.pptxNeoV2
 
See How do animals kill their prey for food
See How do animals kill their prey for foodSee How do animals kill their prey for food
See How do animals kill their prey for fooddrsk203
 
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
 
Soil pollution causes effects remedial measures
Soil pollution causes effects remedial measuresSoil pollution causes effects remedial measures
Soil pollution causes effects remedial measuresvasubhanot1234
 
ENVIRONMENTAL LAW ppt on laws of environmental law
ENVIRONMENTAL LAW ppt on laws of environmental lawENVIRONMENTAL LAW ppt on laws of environmental law
ENVIRONMENTAL LAW ppt on laws of environmental lawnitinraj1000000
 
Delivering nature-based solution outcomes by addressing policy, institutiona...
Delivering nature-based solution outcomes by addressing  policy, institutiona...Delivering nature-based solution outcomes by addressing  policy, institutiona...
Delivering nature-based solution outcomes by addressing policy, institutiona...CIFOR-ICRAF
 
原版定制copy澳洲詹姆斯库克大学毕业证JCU毕业证成绩单留信学历认证保障质量
原版定制copy澳洲詹姆斯库克大学毕业证JCU毕业证成绩单留信学历认证保障质量原版定制copy澳洲詹姆斯库克大学毕业证JCU毕业证成绩单留信学历认证保障质量
原版定制copy澳洲詹姆斯库克大学毕业证JCU毕业证成绩单留信学历认证保障质量sehgh15heh
 
Species composition, diversity and community structure of mangroves in Barang...
Species composition, diversity and community structure of mangroves in Barang...Species composition, diversity and community structure of mangroves in Barang...
Species composition, diversity and community structure of mangroves in Barang...Open Access Research Paper
 
Call In girls Connaught Place (DELHI)⇛9711147426🔝Delhi NCR
Call In girls Connaught Place (DELHI)⇛9711147426🔝Delhi NCRCall In girls Connaught Place (DELHI)⇛9711147426🔝Delhi NCR
Call In girls Connaught Place (DELHI)⇛9711147426🔝Delhi NCRjennyeacort
 
Along the Lakefront, "Menacing Unknown"s
Along the Lakefront, "Menacing Unknown"sAlong the Lakefront, "Menacing Unknown"s
Along the Lakefront, "Menacing Unknown"syalehistoricalreview
 
办理(Victoria毕业证书)维多利亚大学毕业证成绩单原版一比一
办理(Victoria毕业证书)维多利亚大学毕业证成绩单原版一比一办理(Victoria毕业证书)维多利亚大学毕业证成绩单原版一比一
办理(Victoria毕业证书)维多利亚大学毕业证成绩单原版一比一z xss
 
NO1 Famous Amil In Karachi Best Amil In Karachi Bangali Baba In Karachi Aamil...
NO1 Famous Amil In Karachi Best Amil In Karachi Bangali Baba In Karachi Aamil...NO1 Famous Amil In Karachi Best Amil In Karachi Bangali Baba In Karachi Aamil...
NO1 Famous Amil In Karachi Best Amil In Karachi Bangali Baba In Karachi Aamil...Amil baba
 
VIP Call Girls Service Bandlaguda Hyderabad Call +91-8250192130
VIP Call Girls Service Bandlaguda Hyderabad Call +91-8250192130VIP Call Girls Service Bandlaguda Hyderabad Call +91-8250192130
VIP Call Girls Service Bandlaguda Hyderabad Call +91-8250192130Suhani Kapoor
 
Limnology and Wetland Management 2023 NaRM.pptx
Limnology and Wetland Management 2023 NaRM.pptxLimnology and Wetland Management 2023 NaRM.pptx
Limnology and Wetland Management 2023 NaRM.pptxTesfahunTesema
 
Unit 1 - introduction to environmental studies.pdf
Unit 1 - introduction to environmental studies.pdfUnit 1 - introduction to environmental studies.pdf
Unit 1 - introduction to environmental studies.pdfRajjnish1
 

Recently uploaded (20)

885MTAMount DMU University Bachelor's Diploma in Education
885MTAMount DMU University Bachelor's Diploma in Education885MTAMount DMU University Bachelor's Diploma in Education
885MTAMount DMU University Bachelor's Diploma in Education
 
AI and Ecology - The H4rmony Project.pptx
AI and Ecology - The H4rmony Project.pptxAI and Ecology - The H4rmony Project.pptx
AI and Ecology - The H4rmony Project.pptx
 
See How do animals kill their prey for food
See How do animals kill their prey for foodSee How do animals kill their prey for food
See How do animals kill their prey for food
 
Call Girls In R.K. Puram 9953056974 Escorts ServiCe In Delhi Ncr
Call Girls In R.K. Puram 9953056974 Escorts ServiCe In Delhi NcrCall Girls In R.K. Puram 9953056974 Escorts ServiCe In Delhi Ncr
Call Girls In R.K. Puram 9953056974 Escorts ServiCe In Delhi Ncr
 
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...
 
Soil pollution causes effects remedial measures
Soil pollution causes effects remedial measuresSoil pollution causes effects remedial measures
Soil pollution causes effects remedial measures
 
ENVIRONMENTAL LAW ppt on laws of environmental law
ENVIRONMENTAL LAW ppt on laws of environmental lawENVIRONMENTAL LAW ppt on laws of environmental law
ENVIRONMENTAL LAW ppt on laws of environmental law
 
Delivering nature-based solution outcomes by addressing policy, institutiona...
Delivering nature-based solution outcomes by addressing  policy, institutiona...Delivering nature-based solution outcomes by addressing  policy, institutiona...
Delivering nature-based solution outcomes by addressing policy, institutiona...
 
原版定制copy澳洲詹姆斯库克大学毕业证JCU毕业证成绩单留信学历认证保障质量
原版定制copy澳洲詹姆斯库克大学毕业证JCU毕业证成绩单留信学历认证保障质量原版定制copy澳洲詹姆斯库克大学毕业证JCU毕业证成绩单留信学历认证保障质量
原版定制copy澳洲詹姆斯库克大学毕业证JCU毕业证成绩单留信学历认证保障质量
 
Species composition, diversity and community structure of mangroves in Barang...
Species composition, diversity and community structure of mangroves in Barang...Species composition, diversity and community structure of mangroves in Barang...
Species composition, diversity and community structure of mangroves in Barang...
 
Call In girls Connaught Place (DELHI)⇛9711147426🔝Delhi NCR
Call In girls Connaught Place (DELHI)⇛9711147426🔝Delhi NCRCall In girls Connaught Place (DELHI)⇛9711147426🔝Delhi NCR
Call In girls Connaught Place (DELHI)⇛9711147426🔝Delhi NCR
 
Along the Lakefront, "Menacing Unknown"s
Along the Lakefront, "Menacing Unknown"sAlong the Lakefront, "Menacing Unknown"s
Along the Lakefront, "Menacing Unknown"s
 
办理(Victoria毕业证书)维多利亚大学毕业证成绩单原版一比一
办理(Victoria毕业证书)维多利亚大学毕业证成绩单原版一比一办理(Victoria毕业证书)维多利亚大学毕业证成绩单原版一比一
办理(Victoria毕业证书)维多利亚大学毕业证成绩单原版一比一
 
Hot Sexy call girls in Nehru Place, 🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Nehru Place, 🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Nehru Place, 🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Nehru Place, 🔝 9953056974 🔝 escort Service
 
NO1 Famous Amil In Karachi Best Amil In Karachi Bangali Baba In Karachi Aamil...
NO1 Famous Amil In Karachi Best Amil In Karachi Bangali Baba In Karachi Aamil...NO1 Famous Amil In Karachi Best Amil In Karachi Bangali Baba In Karachi Aamil...
NO1 Famous Amil In Karachi Best Amil In Karachi Bangali Baba In Karachi Aamil...
 
young call girls in Janakpuri🔝 9953056974 🔝 escort Service
young call girls in Janakpuri🔝 9953056974 🔝 escort Serviceyoung call girls in Janakpuri🔝 9953056974 🔝 escort Service
young call girls in Janakpuri🔝 9953056974 🔝 escort Service
 
VIP Call Girls Service Bandlaguda Hyderabad Call +91-8250192130
VIP Call Girls Service Bandlaguda Hyderabad Call +91-8250192130VIP Call Girls Service Bandlaguda Hyderabad Call +91-8250192130
VIP Call Girls Service Bandlaguda Hyderabad Call +91-8250192130
 
Limnology and Wetland Management 2023 NaRM.pptx
Limnology and Wetland Management 2023 NaRM.pptxLimnology and Wetland Management 2023 NaRM.pptx
Limnology and Wetland Management 2023 NaRM.pptx
 
Call Girls In { Delhi } South Extension Whatsup 9873940964 Enjoy Unlimited Pl...
Call Girls In { Delhi } South Extension Whatsup 9873940964 Enjoy Unlimited Pl...Call Girls In { Delhi } South Extension Whatsup 9873940964 Enjoy Unlimited Pl...
Call Girls In { Delhi } South Extension Whatsup 9873940964 Enjoy Unlimited Pl...
 
Unit 1 - introduction to environmental studies.pdf
Unit 1 - introduction to environmental studies.pdfUnit 1 - introduction to environmental studies.pdf
Unit 1 - introduction to environmental studies.pdf
 

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