Use calculator
to perform basic arithmetic operations.
The calculator
module provides the following functions:
Adds two numbers.
function add(a: number, b: number): number
a
: The first number.b
: The second number.
The sum of a
and b
.
Subtracts the second number from the first number.
function subtract(a: number, b: number): number
a
: The first number.b
: The second number.
The difference between a
and b
.
Multiplies two numbers.
function multiply(a: number, b: number): number
a
: The first number.b
: The second number.
The product of a
and b
.
Divides the first number by the second number.
function divide(a: number, b: number): number
a
: The first number.b
: The second number.
The quotient of a
divided by b
.
Error
ifb
is 0 (division by zero is not allowed).
Squares a number.
function square(x: number): number
x
: The number to be squared.
The square of x
.
MIT