Modules · Core

Maths

Numbers and the arithmetic over them. The scalar primitives Maths.Real (a float) and Maths.Integer (a whole number) are framework values, like Text and Boolean; the composite types Vector2, Vector3, Vector4 and Quaternion group several reals together. Arithmetic is per type, not overloaded: Maths.Real.Add and Maths.Integer.Add are separate functions, and integer division truncates to a whole number while real division keeps the float. Each operation returns a reactive result that starts loading and settles on its own once its operands are ready, because a driver computes it asynchronously.

Contents

Functions

Functions

Maths.Integer.Add

Adds two integers, giving a whole-number result.

Parameters

NameTypeDescription
aMaths.IntegerThe first integer.
bMaths.IntegerThe second integer.

Returns

A reactive Maths.Integer, loading until its operands settle.

Example

const total = Maths.Integer.Add(2, 3);
A whole-number sum

Maths.Integer.Divide

Divides one integer by another, truncating the result to a whole number.

Parameters

NameTypeDescription
aMaths.IntegerThe dividend.
bMaths.IntegerThe divisor.

Returns

A reactive Maths.Integer; division truncates towards zero.

Example

const half = Maths.Integer.Divide(7, 2);
7 / 2 truncates to 3

Maths.Integer.Multiply

Multiplies two integers.

Parameters

NameTypeDescription
aMaths.IntegerThe first integer.
bMaths.IntegerThe second integer.

Returns

A reactive Maths.Integer, loading until its operands settle.

Example

const area = Maths.Integer.Multiply(4, 5);
A whole-number product

Maths.Integer.Subtract

Subtracts one integer from another.

Parameters

NameTypeDescription
aMaths.IntegerThe integer to subtract from.
bMaths.IntegerThe integer to subtract.

Returns

A reactive Maths.Integer, loading until its operands settle.

Example

const left = Maths.Integer.Subtract(10, 3);
10 minus 3

Maths.Integer.ToString

Turns an integer into text, so it can be shown with Content.Text.

Parameters

NameTypeDescription
valueMaths.IntegerThe integer to stringify.

Returns

A reactive Text.

Example

const count = Maths.Integer.Add(1, 1);
Content.Text(Maths.Integer.ToString(count));
Showing an integer as text

Maths.Real.Add

Adds two real numbers.

Parameters

NameTypeDescription
aMaths.RealThe first number.
bMaths.RealThe second number.

Returns

A reactive Maths.Real, loading until its operands settle.

Example

const sum = Maths.Real.Add(1.5, 2.25);
A real sum

Maths.Real.Divide

Divides one real number by another, keeping the fractional part.

Parameters

NameTypeDescription
aMaths.RealThe dividend.
bMaths.RealThe divisor.

Returns

A reactive Maths.Real; the result keeps the float.

Example

const ratio = Maths.Real.Divide(7, 2);
7 / 2 keeps 3.5

Maths.Real.Multiply

Multiplies two real numbers.

Parameters

NameTypeDescription
aMaths.RealThe first number.
bMaths.RealThe second number.

Returns

A reactive Maths.Real, loading until its operands settle.

Example

const area = Maths.Real.Multiply(2.5, 4);
A real product

Maths.Real.Subtract

Subtracts one real number from another.

Parameters

NameTypeDescription
aMaths.RealThe number to subtract from.
bMaths.RealThe number to subtract.

Returns

A reactive Maths.Real, loading until its operands settle.

Example

const left = Maths.Real.Subtract(5.0, 1.5);
5 minus 1.5

Maths.Real.ToString

Turns a real number into text, so it can be shown with Content.Text.

Parameters

NameTypeDescription
valueMaths.RealThe number to stringify.

Returns

A reactive Text.

Example

const sum = Maths.Real.Add(1.5, 2.25);
Content.Text(Maths.Real.ToString(sum));
Showing a real value as text