SlideShare a Scribd company logo
Arithmetic in JavaScript
Mathematical operations
Arithmetic in JavaScript
• JavaScript programs work with numbers
using the arithmetic operators that the
language provides.
Arithmetic in JavaScript
• + for addition,
• - for subtraction,
• * for multiplication,
• / for division,
• and % for modulo.
Arithmetic in JavaScript
• + for addition,
• - for subtraction,
• * for multiplication,
• / for division,
• and % for modulo.
Arithmetic in JavaScript
• JavaScript supports more complex
mathematical operations through a
set of functions and constants defined
as properties of the Math object.
Arithmetic in JavaScript
Arithmetic in JavaScript
• Arithmetic in JavaScript does not raise
errors in cases of overflow,
underflow, or division by zero.
Arithmetic in JavaScript
• When the result of a numeric operation is
larger than the largest
representable number (overflow),
the result is a special infinity value, which
JavaScript prints as Infinity.
Arithmetic in JavaScript
• when a negative value becomes larger
than the largest representable negative
number, the result is negative infinity,
printed as -Infinity.
Arithmetic in JavaScript
• When a negative value becomes larger
than the largest representable negative
number, the result is negative infinity,
printed as -Infinity.
Arithmetic in JavaScript
• Underflow occurs when the result of a
numeric operation is closer to
zero than the smallest representable
number.
• In this case, JavaScript returns 0.
Arithmetic in JavaScript
• If underflow occurs from a
negative number,
• JavaScript returns a special value known
as “negative zero.”
Arithmetic in JavaScript
• Division by zero is not an error in
JavaScript: it simply returns infinity or
negative infinity.
• 0/0 is not Infinity
• There is one exception!!
Arithmetic in JavaScript
• zero divided by zero does not have a
well defined value, and the result of
this operation is the special not-a-
number value, printed as NaN.
• 0/0 = NaN
Arithmetic in JavaScript
• NaN also arises if you attempt to
divide infinity by infinity.
• take the square root of a negative
number (NaN).
Arithmetic in JavaScript

More Related Content

Viewers also liked (6)

Javascript Canvas API
Javascript Canvas APIJavascript Canvas API
Javascript Canvas API
Samuel Santos
 
Javascript - Array - Creating Array
Javascript - Array - Creating ArrayJavascript - Array - Creating Array
Javascript - Array - Creating Array
Samuel Santos
 
Javascript - ADT - List - Implementation
Javascript - ADT -  List - ImplementationJavascript - ADT -  List - Implementation
Javascript - ADT - List - Implementation
Samuel Santos
 
Javascript ADT - List
Javascript   ADT - ListJavascript   ADT - List
Javascript ADT - List
Samuel Santos
 
Euler
EulerEuler
Euler
hosseinnnik
 
Java Stack (Pilha)
Java Stack (Pilha)Java Stack (Pilha)
Java Stack (Pilha)
Samuel Santos
 
Javascript Canvas API
Javascript Canvas APIJavascript Canvas API
Javascript Canvas API
Samuel Santos
 
Javascript - Array - Creating Array
Javascript - Array - Creating ArrayJavascript - Array - Creating Array
Javascript - Array - Creating Array
Samuel Santos
 
Javascript - ADT - List - Implementation
Javascript - ADT -  List - ImplementationJavascript - ADT -  List - Implementation
Javascript - ADT - List - Implementation
Samuel Santos
 
Javascript ADT - List
Javascript   ADT - ListJavascript   ADT - List
Javascript ADT - List
Samuel Santos
 

Similar to Javascript - Arithmetic in Javascript (20)

Performing calculations using java script
Performing calculations using java scriptPerforming calculations using java script
Performing calculations using java script
Jesus Obenita Jr.
 
Digital textbook
Digital textbookDigital textbook
Digital textbook
anumolkm
 
IOS Swift Language 3rd tutorial
IOS Swift Language 3rd tutorialIOS Swift Language 3rd tutorial
IOS Swift Language 3rd tutorial
Hassan A-j
 
Maths project
Maths projectMaths project
Maths project
Ruchi Dixit
 
Lesson4 integers
Lesson4 integersLesson4 integers
Lesson4 integers
Mercedes López
 
Unit 5 integers
Unit 5 integersUnit 5 integers
Unit 5 integers
Educación
 
1-Introduction-to-Maths.pdf
1-Introduction-to-Maths.pdf1-Introduction-to-Maths.pdf
1-Introduction-to-Maths.pdf
lordivinaPelegrino
 
Integers
IntegersIntegers
Integers
Deepansha Singh
 
Integers
IntegersIntegers
Integers
Aaron James Lico
 
Integers
IntegersIntegers
Integers
Aaron James Lico
 
GYANOME: NCERT 6th Mathematics Chapter 1 - Knowing our numbers
GYANOME: NCERT 6th Mathematics Chapter 1 - Knowing our numbers GYANOME: NCERT 6th Mathematics Chapter 1 - Knowing our numbers
GYANOME: NCERT 6th Mathematics Chapter 1 - Knowing our numbers
Swapnil Deopurkar
 
Chapter 1 Directed Numbers
Chapter 1 Directed NumbersChapter 1 Directed Numbers
Chapter 1 Directed Numbers
Angelyn Yap
 
Integer (Math)
Integer (Math)Integer (Math)
Integer (Math)
SophiaLi2
 
Integer (Math)
Integer (Math)Integer (Math)
Integer (Math)
SophiaLi2
 
Number and operations review1
Number and operations review1Number and operations review1
Number and operations review1
Institute of Applied Technology
 
05 Performing Fundamental Operations on Integers.pptx
05 Performing Fundamental Operations on Integers.pptx05 Performing Fundamental Operations on Integers.pptx
05 Performing Fundamental Operations on Integers.pptx
MerrykrisIgnacio
 
1.1 and 1.2
1.1 and 1.21.1 and 1.2
1.1 and 1.2
leblance
 
Unit 1. Integers
Unit 1. IntegersUnit 1. Integers
Unit 1. Integers
balastslide
 
In- Built Math function in java script..
In- Built Math function in java script..In- Built Math function in java script..
In- Built Math function in java script..
anjanasharma77573
 
General mathematics
General mathematicsGeneral mathematics
General mathematics
Boyet Aluan
 
Performing calculations using java script
Performing calculations using java scriptPerforming calculations using java script
Performing calculations using java script
Jesus Obenita Jr.
 
Digital textbook
Digital textbookDigital textbook
Digital textbook
anumolkm
 
IOS Swift Language 3rd tutorial
IOS Swift Language 3rd tutorialIOS Swift Language 3rd tutorial
IOS Swift Language 3rd tutorial
Hassan A-j
 
Unit 5 integers
Unit 5 integersUnit 5 integers
Unit 5 integers
Educación
 
GYANOME: NCERT 6th Mathematics Chapter 1 - Knowing our numbers
GYANOME: NCERT 6th Mathematics Chapter 1 - Knowing our numbers GYANOME: NCERT 6th Mathematics Chapter 1 - Knowing our numbers
GYANOME: NCERT 6th Mathematics Chapter 1 - Knowing our numbers
Swapnil Deopurkar
 
Chapter 1 Directed Numbers
Chapter 1 Directed NumbersChapter 1 Directed Numbers
Chapter 1 Directed Numbers
Angelyn Yap
 
Integer (Math)
Integer (Math)Integer (Math)
Integer (Math)
SophiaLi2
 
Integer (Math)
Integer (Math)Integer (Math)
Integer (Math)
SophiaLi2
 
05 Performing Fundamental Operations on Integers.pptx
05 Performing Fundamental Operations on Integers.pptx05 Performing Fundamental Operations on Integers.pptx
05 Performing Fundamental Operations on Integers.pptx
MerrykrisIgnacio
 
1.1 and 1.2
1.1 and 1.21.1 and 1.2
1.1 and 1.2
leblance
 
Unit 1. Integers
Unit 1. IntegersUnit 1. Integers
Unit 1. Integers
balastslide
 
In- Built Math function in java script..
In- Built Math function in java script..In- Built Math function in java script..
In- Built Math function in java script..
anjanasharma77573
 
General mathematics
General mathematicsGeneral mathematics
General mathematics
Boyet Aluan
 
Ad

Recently uploaded (20)

Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AIReimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
What is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdfWhat is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdf
Varsha Nayak
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines OperationsHow Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
OpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native BarcelonaOpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native Barcelona
Imma Valls Bernaus
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized InnovationAdvanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptxMOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
Maharshi Mallela
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across IndustriesArtificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
Who will create the languages of the future?
Who will create the languages of the future?Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptxwAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.pptSAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
Zoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutionsZoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutions
reenashriee
 
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptxIMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
usmanch7829
 
Open Source Software Development Methods
Open Source Software Development MethodsOpen Source Software Development Methods
Open Source Software Development Methods
VICTOR MAESTRE RAMIREZ
 
Integrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FMEIntegrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FME
Safe Software
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - IntroductionIBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
Transmission Media. (Computer Networks)
Transmission Media.  (Computer Networks)Transmission Media.  (Computer Networks)
Transmission Media. (Computer Networks)
S Pranav (Deepu)
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration KeySmadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
Making significant Software Architecture decisions
Making significant Software Architecture decisionsMaking significant Software Architecture decisions
Making significant Software Architecture decisions
Bert Jan Schrijver
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 WebinarPorting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AIReimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
What is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdfWhat is data visualization and how data visualization tool can help.pdf
What is data visualization and how data visualization tool can help.pdf
Varsha Nayak
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines OperationsHow Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
OpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native BarcelonaOpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native Barcelona
Imma Valls Bernaus
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized InnovationAdvanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptxMOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
Maharshi Mallela
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across IndustriesArtificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
Who will create the languages of the future?
Who will create the languages of the future?Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptxwAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.pptSAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
Zoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutionsZoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutions
reenashriee
 
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptxIMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
usmanch7829
 
Open Source Software Development Methods
Open Source Software Development MethodsOpen Source Software Development Methods
Open Source Software Development Methods
VICTOR MAESTRE RAMIREZ
 
Integrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FMEIntegrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FME
Safe Software
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - IntroductionIBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
Transmission Media. (Computer Networks)
Transmission Media.  (Computer Networks)Transmission Media.  (Computer Networks)
Transmission Media. (Computer Networks)
S Pranav (Deepu)
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration KeySmadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
Making significant Software Architecture decisions
Making significant Software Architecture decisionsMaking significant Software Architecture decisions
Making significant Software Architecture decisions
Bert Jan Schrijver
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 WebinarPorting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
Ad

Javascript - Arithmetic in Javascript