SlideShare a Scribd company logo
Calculating garbage
value in case of Overflow
Garbage value in C
 In a language like C, when you define a variable, like:
int x;
 A small block of memory is allocated to the variable. However, we
have only declared the variable, and not initialized it, which means
that the block of memory that has been allocated to the variable still
contains some value that has been left over from previous programs
and operations. That value is called a garbage value. This may lead
to erroneous results in programs.
 To avoid this, declare and initialize variables like this:
int x = 0;
In case of Windows
 The space allocated for a variable of int datatype is 16 bits.
 That means the maximum negative value that can be stored by the
variable of int datatype is 2^15=-32768.
 You may ask why 2^15 not 2^16.
 This is because one bit is reserved for sign(+ or -)
 Similarly the maximum +ve value that a variable of int datatype can
store is 2^15-1=32767.
 Why -1.Because 0 is also counted in case of +ve values.
 Now lets come to long datatype.
 The space allocated for a variable of int datatype is 32 bits.
Maximum negative value= 2^31= -2147483648
Maximum +ve value= 2^31-1=2147483647
 The space allocated for a variable of long datatype is 64 bits.
Maximum negative value= 2^63= -9.22337e+18
Maximum +ve value= (2^63)-1= 9.22337e+18
Formula for calculating garbage value
garbage value=overflow value-reference value.
reference value is the value such that it is greater than the
overflow value(neglecting the sign)
obtained by the multiplication of the basic reference value by 2
until the value is greater than the overflow value(neglecting the
sign)
The sign of the reference value is same as that of overflow
value.
Basic reference value is 2^n where n represents the number of
bits allocated.
The garbage value thus calculated is checked whether it can fit
the variable or not. If not the steps are repeated again.
Basic reference value=32768
since the reference value is less than the overflow value
,we have to multiply it by 2
i.e,32768*2=65536
65536 is greater than the 45000.That means reference
value(RV)=65536.SInce RV must be of same
sign,RV=+65536
1. now apply formula
2. garbage value=overflow value-reference value.
3. garbage value=45000-(+65536)
4. garbage value=-20536
5. -20536 comes within the limits of int datatype.
Lets understand what happens.
That means.
OV=32768 Basic RV=32768.
RV must be greater than OV.
Therfore RV=32768*2=65536
Now, garbage value(GV)=OV-RV=32768-65536=-32768
Since both variables a
and b are assigned a
value greater than their
limits, when you run this
program some garbage
value will be the output.
2^31
RV>OV
Calculating garbage value in case of overflow
Calculating garbage value in case of overflow
Calculating garbage value in case of overflow

More Related Content

What's hot

Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 80869840596838
 
Microchip's 16-bit and 32-bit PIC MCUs
Microchip's 16-bit and 32-bit PIC MCUsMicrochip's 16-bit and 32-bit PIC MCUs
Microchip's 16-bit and 32-bit PIC MCUs
Premier Farnell
 
8085 microprocessor(1)
8085 microprocessor(1)8085 microprocessor(1)
8085 microprocessor(1)Reevu Pal
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
Subhasis Dash
 
Operand and Opcode | Computer Science
Operand and Opcode | Computer ScienceOperand and Opcode | Computer Science
Operand and Opcode | Computer Science
Transweb Global Inc
 
8255 programming
8255 programming8255 programming
8255 programming
Jeyalaksmi V Professor ECE
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and Architecture
Vinit Raut
 
Nyquist criterion for distortion less baseband binary channel
Nyquist criterion for distortion less baseband binary channelNyquist criterion for distortion less baseband binary channel
Nyquist criterion for distortion less baseband binary channel
PriyangaKR1
 
Presentation on 8086 Microprocessor
Presentation  on   8086 MicroprocessorPresentation  on   8086 Microprocessor
Presentation on 8086 Microprocessor
Nahian Ahmed
 
8086 module 1 & 2 work
8086 module 1 & 2   work8086 module 1 & 2   work
8086 module 1 & 2 work
Suhail Km
 
Subroutine & string in 8086 Microprocessor
Subroutine & string in 8086 MicroprocessorSubroutine & string in 8086 Microprocessor
Subroutine & string in 8086 Microprocessor
Mustafa AL-Timemmie
 
Instruction set of 8085
Instruction set  of 8085Instruction set  of 8085
Instruction set of 8085
shiji v r
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
Shehrevar Davierwala
 
Instruction format
Instruction formatInstruction format
Instruction format
Sanjeev Patel
 
8051 micro controllers Instruction set
8051 micro controllers Instruction set 8051 micro controllers Instruction set
8051 micro controllers Instruction set
Nitin Ahire
 
Logical Instructions used in 8086 microprocessor
Logical Instructions used in 8086 microprocessorLogical Instructions used in 8086 microprocessor
Logical Instructions used in 8086 microprocessor
Rabin BK
 
Linear block coding
Linear block codingLinear block coding
Linear block coding
jknm
 
MICROPROCESSOR INSTRUCTION SET OF 8085
MICROPROCESSOR INSTRUCTION SET OF 8085MICROPROCESSOR INSTRUCTION SET OF 8085
MICROPROCESSOR INSTRUCTION SET OF 8085
Sumadeep Juvvalapalem
 
Chapter 05 computer arithmetic
Chapter 05 computer arithmeticChapter 05 computer arithmetic
Chapter 05 computer arithmeticIIUI
 
Module 5 part1
Module 5 part1Module 5 part1
Module 5 part1
cs19club
 

What's hot (20)

Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Microchip's 16-bit and 32-bit PIC MCUs
Microchip's 16-bit and 32-bit PIC MCUsMicrochip's 16-bit and 32-bit PIC MCUs
Microchip's 16-bit and 32-bit PIC MCUs
 
8085 microprocessor(1)
8085 microprocessor(1)8085 microprocessor(1)
8085 microprocessor(1)
 
High Performance Computer Architecture
High Performance Computer ArchitectureHigh Performance Computer Architecture
High Performance Computer Architecture
 
Operand and Opcode | Computer Science
Operand and Opcode | Computer ScienceOperand and Opcode | Computer Science
Operand and Opcode | Computer Science
 
8255 programming
8255 programming8255 programming
8255 programming
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and Architecture
 
Nyquist criterion for distortion less baseband binary channel
Nyquist criterion for distortion less baseband binary channelNyquist criterion for distortion less baseband binary channel
Nyquist criterion for distortion less baseband binary channel
 
Presentation on 8086 Microprocessor
Presentation  on   8086 MicroprocessorPresentation  on   8086 Microprocessor
Presentation on 8086 Microprocessor
 
8086 module 1 & 2 work
8086 module 1 & 2   work8086 module 1 & 2   work
8086 module 1 & 2 work
 
Subroutine & string in 8086 Microprocessor
Subroutine & string in 8086 MicroprocessorSubroutine & string in 8086 Microprocessor
Subroutine & string in 8086 Microprocessor
 
Instruction set of 8085
Instruction set  of 8085Instruction set  of 8085
Instruction set of 8085
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
Instruction format
Instruction formatInstruction format
Instruction format
 
8051 micro controllers Instruction set
8051 micro controllers Instruction set 8051 micro controllers Instruction set
8051 micro controllers Instruction set
 
Logical Instructions used in 8086 microprocessor
Logical Instructions used in 8086 microprocessorLogical Instructions used in 8086 microprocessor
Logical Instructions used in 8086 microprocessor
 
Linear block coding
Linear block codingLinear block coding
Linear block coding
 
MICROPROCESSOR INSTRUCTION SET OF 8085
MICROPROCESSOR INSTRUCTION SET OF 8085MICROPROCESSOR INSTRUCTION SET OF 8085
MICROPROCESSOR INSTRUCTION SET OF 8085
 
Chapter 05 computer arithmetic
Chapter 05 computer arithmeticChapter 05 computer arithmetic
Chapter 05 computer arithmetic
 
Module 5 part1
Module 5 part1Module 5 part1
Module 5 part1
 

Viewers also liked

Перший рік навчання
Перший рік навчанняПерший рік навчання
Перший рік навчання
Тамара Тарасюк
 
CV_DATTATRY DESHMUKH_LIFERAY_JAVA_IAM
CV_DATTATRY DESHMUKH_LIFERAY_JAVA_IAMCV_DATTATRY DESHMUKH_LIFERAY_JAVA_IAM
CV_DATTATRY DESHMUKH_LIFERAY_JAVA_IAMDattatray Deshmukh
 
Cameras to secure hospitals
Cameras to secure hospitalsCameras to secure hospitals
Cameras to secure hospitals
Other Mother
 
Exciting news for stakeholders...
Exciting news for stakeholders...Exciting news for stakeholders...
Exciting news for stakeholders...
lisawiz
 
Lennart guldbrandsson internetdagarna 2015
Lennart guldbrandsson internetdagarna 2015Lennart guldbrandsson internetdagarna 2015
Lennart guldbrandsson internetdagarna 2015
Lennart Guldbrandsson
 
Virtualization & Plant PAx
Virtualization & Plant PAxVirtualization & Plant PAx
Virtualization & Plant PAx
Avanceon-Lahore
 
Place_Report_2013
Place_Report_2013Place_Report_2013
Place_Report_2013David Grant
 
Aktiivinen tulevaisuus
Aktiivinen tulevaisuusAktiivinen tulevaisuus
Aktiivinen tulevaisuus
Turun kaupunki
 
Restauracion
RestauracionRestauracion
Restauracion
aimargazte
 
Презентація на тему: "Глобальні проблеми людства"
Презентація на тему: "Глобальні проблеми людства"Презентація на тему: "Глобальні проблеми людства"
Презентація на тему: "Глобальні проблеми людства"
Jennie Ice
 
Sharing one successful Erasmus+ project proposal
Sharing one successful Erasmus+ project proposalSharing one successful Erasmus+ project proposal
Sharing one successful Erasmus+ project proposal
Gustavo Alves
 

Viewers also liked (12)

Перший рік навчання
Перший рік навчанняПерший рік навчання
Перший рік навчання
 
CV_DATTATRY DESHMUKH_LIFERAY_JAVA_IAM
CV_DATTATRY DESHMUKH_LIFERAY_JAVA_IAMCV_DATTATRY DESHMUKH_LIFERAY_JAVA_IAM
CV_DATTATRY DESHMUKH_LIFERAY_JAVA_IAM
 
Cameras to secure hospitals
Cameras to secure hospitalsCameras to secure hospitals
Cameras to secure hospitals
 
Exciting news for stakeholders...
Exciting news for stakeholders...Exciting news for stakeholders...
Exciting news for stakeholders...
 
Lennart guldbrandsson internetdagarna 2015
Lennart guldbrandsson internetdagarna 2015Lennart guldbrandsson internetdagarna 2015
Lennart guldbrandsson internetdagarna 2015
 
Virtualization & Plant PAx
Virtualization & Plant PAxVirtualization & Plant PAx
Virtualization & Plant PAx
 
Place_Report_2013
Place_Report_2013Place_Report_2013
Place_Report_2013
 
Aktiivinen tulevaisuus
Aktiivinen tulevaisuusAktiivinen tulevaisuus
Aktiivinen tulevaisuus
 
Maciel abr-2003
Maciel abr-2003Maciel abr-2003
Maciel abr-2003
 
Restauracion
RestauracionRestauracion
Restauracion
 
Презентація на тему: "Глобальні проблеми людства"
Презентація на тему: "Глобальні проблеми людства"Презентація на тему: "Глобальні проблеми людства"
Презентація на тему: "Глобальні проблеми людства"
 
Sharing one successful Erasmus+ project proposal
Sharing one successful Erasmus+ project proposalSharing one successful Erasmus+ project proposal
Sharing one successful Erasmus+ project proposal
 

Similar to Calculating garbage value in case of overflow

DLD_PPT_0.pptx
DLD_PPT_0.pptxDLD_PPT_0.pptx
DLD_PPT_0.pptx
ECENAAC2
 
IS 139 Lecture 4
IS 139 Lecture 4IS 139 Lecture 4
IS 139 Lecture 4
wajanga
 
IS 139 Lecture 4 - 2015
IS 139 Lecture 4 - 2015IS 139 Lecture 4 - 2015
IS 139 Lecture 4 - 2015
Aron Kondoro
 
Lec 02 data representation part 1
Lec 02 data representation part 1Lec 02 data representation part 1
Lec 02 data representation part 1Abdul Khan
 
Lesson 13. Pattern 5. Address arithmetic
Lesson 13. Pattern 5. Address arithmeticLesson 13. Pattern 5. Address arithmetic
Lesson 13. Pattern 5. Address arithmetic
PVS-Studio
 
Unit 1 data representation and computer arithmetic
Unit 1  data representation and computer arithmeticUnit 1  data representation and computer arithmetic
Unit 1 data representation and computer arithmetic
AmrutaMehata
 
1. Number System in Digital Electronics.pptx
1. Number System in Digital Electronics.pptx1. Number System in Digital Electronics.pptx
1. Number System in Digital Electronics.pptx
Nehachandran2
 
Lecture 02 - Logic Design(Number Systems).pptx
Lecture 02 - Logic Design(Number Systems).pptxLecture 02 - Logic Design(Number Systems).pptx
Lecture 02 - Logic Design(Number Systems).pptx
shwan it
 
Representation of Integers
Representation of IntegersRepresentation of Integers
Representation of Integers
Susantha Herath
 
IARE_DLD_PPT_0.pdf
IARE_DLD_PPT_0.pdfIARE_DLD_PPT_0.pdf
IARE_DLD_PPT_0.pdf
nirbhay singh
 
1. Digital Electronics Number System.pdf
1. Digital Electronics Number System.pdf1. Digital Electronics Number System.pdf
1. Digital Electronics Number System.pdf
Nehachandran2
 
Switching circuits and logic design
Switching circuits and logic designSwitching circuits and logic design
Switching circuits and logic design
goutamkrsahoo
 
Lesson 17. Pattern 9. Mixed arithmetic
Lesson 17. Pattern 9. Mixed arithmeticLesson 17. Pattern 9. Mixed arithmetic
Lesson 17. Pattern 9. Mixed arithmetic
PVS-Studio
 
chapter one && two.pdf
chapter one && two.pdfchapter one && two.pdf
chapter one && two.pdf
miftah88
 
numbers_systems.ppt
numbers_systems.pptnumbers_systems.ppt
numbers_systems.ppt
sulekhasaxena2
 
numbers_systems.ppt
numbers_systems.pptnumbers_systems.ppt
numbers_systems.ppt
Suganthi Vasanth Raj
 
numbers_systems.ppt
numbers_systems.pptnumbers_systems.ppt
numbers_systems.ppt
IsfahanAhmed3
 
numbers_systems.pptx
numbers_systems.pptxnumbers_systems.pptx
numbers_systems.pptx
MohammedtajuddinTaju
 
numbers_systems (1).ppt
numbers_systems (1).pptnumbers_systems (1).ppt
numbers_systems (1).ppt
YashNaware2
 

Similar to Calculating garbage value in case of overflow (20)

DLD_PPT_0.pptx
DLD_PPT_0.pptxDLD_PPT_0.pptx
DLD_PPT_0.pptx
 
IS 139 Lecture 4
IS 139 Lecture 4IS 139 Lecture 4
IS 139 Lecture 4
 
IS 139 Lecture 4 - 2015
IS 139 Lecture 4 - 2015IS 139 Lecture 4 - 2015
IS 139 Lecture 4 - 2015
 
Lec 02 data representation part 1
Lec 02 data representation part 1Lec 02 data representation part 1
Lec 02 data representation part 1
 
Lesson 13. Pattern 5. Address arithmetic
Lesson 13. Pattern 5. Address arithmeticLesson 13. Pattern 5. Address arithmetic
Lesson 13. Pattern 5. Address arithmetic
 
Unit 1 data representation and computer arithmetic
Unit 1  data representation and computer arithmeticUnit 1  data representation and computer arithmetic
Unit 1 data representation and computer arithmetic
 
1. Number System in Digital Electronics.pptx
1. Number System in Digital Electronics.pptx1. Number System in Digital Electronics.pptx
1. Number System in Digital Electronics.pptx
 
Lecture 02 - Logic Design(Number Systems).pptx
Lecture 02 - Logic Design(Number Systems).pptxLecture 02 - Logic Design(Number Systems).pptx
Lecture 02 - Logic Design(Number Systems).pptx
 
Representation of Integers
Representation of IntegersRepresentation of Integers
Representation of Integers
 
IARE_DLD_PPT_0.pdf
IARE_DLD_PPT_0.pdfIARE_DLD_PPT_0.pdf
IARE_DLD_PPT_0.pdf
 
C code examples
C code examplesC code examples
C code examples
 
1. Digital Electronics Number System.pdf
1. Digital Electronics Number System.pdf1. Digital Electronics Number System.pdf
1. Digital Electronics Number System.pdf
 
Switching circuits and logic design
Switching circuits and logic designSwitching circuits and logic design
Switching circuits and logic design
 
Lesson 17. Pattern 9. Mixed arithmetic
Lesson 17. Pattern 9. Mixed arithmeticLesson 17. Pattern 9. Mixed arithmetic
Lesson 17. Pattern 9. Mixed arithmetic
 
chapter one && two.pdf
chapter one && two.pdfchapter one && two.pdf
chapter one && two.pdf
 
numbers_systems.ppt
numbers_systems.pptnumbers_systems.ppt
numbers_systems.ppt
 
numbers_systems.ppt
numbers_systems.pptnumbers_systems.ppt
numbers_systems.ppt
 
numbers_systems.ppt
numbers_systems.pptnumbers_systems.ppt
numbers_systems.ppt
 
numbers_systems.pptx
numbers_systems.pptxnumbers_systems.pptx
numbers_systems.pptx
 
numbers_systems (1).ppt
numbers_systems (1).pptnumbers_systems (1).ppt
numbers_systems (1).ppt
 

More from Jasleen Kaur (Chandigarh University)

Graphs data structures
Graphs data structuresGraphs data structures
Graphs data structures
Jasleen Kaur (Chandigarh University)
 
B+ trees and height balance tree
B+ trees and height balance treeB+ trees and height balance tree
B+ trees and height balance tree
Jasleen Kaur (Chandigarh University)
 
Basics of c++
Basics of c++Basics of c++
Static variables
Static variablesStatic variables
Operating system notes pdf
Operating system notes pdfOperating system notes pdf
Operating system notes pdf
Jasleen Kaur (Chandigarh University)
 
Priority Based Congestion Avoidance Hybrid Scheme published in IEEE
Priority Based Congestion Avoidance Hybrid Scheme published in IEEE Priority Based Congestion Avoidance Hybrid Scheme published in IEEE
Priority Based Congestion Avoidance Hybrid Scheme published in IEEE
Jasleen Kaur (Chandigarh University)
 
03 function overloading
03 function overloading03 function overloading
03 function overloading
Jasleen Kaur (Chandigarh University)
 
Chapter 2.datatypes and operators
Chapter 2.datatypes and operatorsChapter 2.datatypes and operators
Chapter 2.datatypes and operators
Jasleen Kaur (Chandigarh University)
 
Chapter 1
Chapter 1Chapter 1
Remote desktop connection
Remote desktop connectionRemote desktop connection
Remote desktop connection
Jasleen Kaur (Chandigarh University)
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
Jasleen Kaur (Chandigarh University)
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
Jasleen Kaur (Chandigarh University)
 
Final jasleen ppt
Final jasleen pptFinal jasleen ppt
License Plate recognition
License Plate recognitionLicense Plate recognition
License Plate recognition
Jasleen Kaur (Chandigarh University)
 
The solar system
The solar system The solar system
The solar system
The solar systemThe solar system
Afforestation environmental issue
Afforestation environmental issueAfforestation environmental issue
Afforestation environmental issue
Jasleen Kaur (Chandigarh University)
 
Data aggregation in wireless sensor networks
Data aggregation in wireless sensor networksData aggregation in wireless sensor networks
Data aggregation in wireless sensor networks
Jasleen Kaur (Chandigarh University)
 

More from Jasleen Kaur (Chandigarh University) (19)

Graphs data structures
Graphs data structuresGraphs data structures
Graphs data structures
 
B+ trees and height balance tree
B+ trees and height balance treeB+ trees and height balance tree
B+ trees and height balance tree
 
Basics of c++
Basics of c++Basics of c++
Basics of c++
 
Static variables
Static variablesStatic variables
Static variables
 
Operating system notes pdf
Operating system notes pdfOperating system notes pdf
Operating system notes pdf
 
Priority Based Congestion Avoidance Hybrid Scheme published in IEEE
Priority Based Congestion Avoidance Hybrid Scheme published in IEEE Priority Based Congestion Avoidance Hybrid Scheme published in IEEE
Priority Based Congestion Avoidance Hybrid Scheme published in IEEE
 
03 function overloading
03 function overloading03 function overloading
03 function overloading
 
Chapter 2.datatypes and operators
Chapter 2.datatypes and operatorsChapter 2.datatypes and operators
Chapter 2.datatypes and operators
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Remote desktop connection
Remote desktop connectionRemote desktop connection
Remote desktop connection
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
 
Final jasleen ppt
Final jasleen pptFinal jasleen ppt
Final jasleen ppt
 
License Plate recognition
License Plate recognitionLicense Plate recognition
License Plate recognition
 
The solar system
The solar system The solar system
The solar system
 
The solar system
The solar systemThe solar system
The solar system
 
Afforestation environmental issue
Afforestation environmental issueAfforestation environmental issue
Afforestation environmental issue
 
Data aggregation in wireless sensor networks
Data aggregation in wireless sensor networksData aggregation in wireless sensor networks
Data aggregation in wireless sensor networks
 
Network security
Network securityNetwork security
Network security
 

Recently uploaded

6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABSDESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
itech2017
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Steel & Timber Design according to British Standard
Steel & Timber Design according to British StandardSteel & Timber Design according to British Standard
Steel & Timber Design according to British Standard
AkolbilaEmmanuel1
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
ssuser7dcef0
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
top1002
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 

Recently uploaded (20)

6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABSDESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
DESIGN AND ANALYSIS OF A CAR SHOWROOM USING E TABS
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Steel & Timber Design according to British Standard
Steel & Timber Design according to British StandardSteel & Timber Design according to British Standard
Steel & Timber Design according to British Standard
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 

Calculating garbage value in case of overflow

  • 1. Calculating garbage value in case of Overflow
  • 2. Garbage value in C  In a language like C, when you define a variable, like: int x;  A small block of memory is allocated to the variable. However, we have only declared the variable, and not initialized it, which means that the block of memory that has been allocated to the variable still contains some value that has been left over from previous programs and operations. That value is called a garbage value. This may lead to erroneous results in programs.  To avoid this, declare and initialize variables like this: int x = 0;
  • 3. In case of Windows  The space allocated for a variable of int datatype is 16 bits.  That means the maximum negative value that can be stored by the variable of int datatype is 2^15=-32768.  You may ask why 2^15 not 2^16.  This is because one bit is reserved for sign(+ or -)  Similarly the maximum +ve value that a variable of int datatype can store is 2^15-1=32767.  Why -1.Because 0 is also counted in case of +ve values.
  • 4.  Now lets come to long datatype.  The space allocated for a variable of int datatype is 32 bits. Maximum negative value= 2^31= -2147483648 Maximum +ve value= 2^31-1=2147483647  The space allocated for a variable of long datatype is 64 bits. Maximum negative value= 2^63= -9.22337e+18 Maximum +ve value= (2^63)-1= 9.22337e+18
  • 5. Formula for calculating garbage value garbage value=overflow value-reference value. reference value is the value such that it is greater than the overflow value(neglecting the sign) obtained by the multiplication of the basic reference value by 2 until the value is greater than the overflow value(neglecting the sign) The sign of the reference value is same as that of overflow value. Basic reference value is 2^n where n represents the number of bits allocated. The garbage value thus calculated is checked whether it can fit the variable or not. If not the steps are repeated again.
  • 6. Basic reference value=32768 since the reference value is less than the overflow value ,we have to multiply it by 2 i.e,32768*2=65536 65536 is greater than the 45000.That means reference value(RV)=65536.SInce RV must be of same sign,RV=+65536 1. now apply formula 2. garbage value=overflow value-reference value. 3. garbage value=45000-(+65536) 4. garbage value=-20536 5. -20536 comes within the limits of int datatype.
  • 7. Lets understand what happens. That means. OV=32768 Basic RV=32768. RV must be greater than OV. Therfore RV=32768*2=65536 Now, garbage value(GV)=OV-RV=32768-65536=-32768
  • 8. Since both variables a and b are assigned a value greater than their limits, when you run this program some garbage value will be the output.