Skip to content

Arithmetic

github-actions[bot] edited this page Jan 24, 2024 · 2 revisions

Namespace: Arithmetic

Arithmetic module for basic arithmetic operations.

Table of contents

Functions

Functions

add

add(x, y): number

Adds two numbers.

Parameters

Name Type Description
x number The first number.
y number The second number.

Returns

number

The sum of the two numbers.

Example

// Return 2:
add(1, 1);

Example

// Return 4:
add(3, 1);

Defined in

arithmetic.ts:22


div

div(x, y): number

Divides two numbers.

Parameters

Name Type Description
x number The first number.
y number The second number.

Returns

number

The quotient of the two numbers.

Example

// Return 1:
div(1, 1);

Example

// Return 3:
div(3, 1);

Example

// Return -0.3333333333333333:
div(1, -3);

Defined in

arithmetic.ts:97


mul

mul(x, y): number

Multiplies two numbers.

Parameters

Name Type Description
x number The first number.
y number The second number.

Returns

number

The product of the two numbers.

Example

// Return 1:
mul(1, 1);

Example

// Return 3:
mul(3, 1);

Example

// Return -3:
mul(1, -3);

Defined in

arithmetic.ts:72


sub

sub(x, y): number

Subtracts two numbers.

Parameters

Name Type Description
x number The first number.
y number The second number.

Returns

number

The difference of the two numbers.

Example

// Return 0:
sub(1, 1);

Example

// Return 2:
sub(3, 1);

Example

// Return -2:
sub(1, 3);

Defined in

arithmetic.ts:47