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
| Name | Type | Description |
|---|---|---|
a | Maths.Integer | The first integer. |
b | Maths.Integer | The second integer. |
Returns
A reactive Maths.Integer, loading until its operands settle.
Example
const total = Maths.Integer.Add(2, 3);Maths.Integer.Divide
Divides one integer by another, truncating the result to a whole number.
Parameters
| Name | Type | Description |
|---|---|---|
a | Maths.Integer | The dividend. |
b | Maths.Integer | The divisor. |
Returns
A reactive Maths.Integer; division truncates towards zero.
Example
const half = Maths.Integer.Divide(7, 2);Maths.Integer.Multiply
Multiplies two integers.
Parameters
| Name | Type | Description |
|---|---|---|
a | Maths.Integer | The first integer. |
b | Maths.Integer | The second integer. |
Returns
A reactive Maths.Integer, loading until its operands settle.
Example
const area = Maths.Integer.Multiply(4, 5);Maths.Integer.Subtract
Subtracts one integer from another.
Parameters
| Name | Type | Description |
|---|---|---|
a | Maths.Integer | The integer to subtract from. |
b | Maths.Integer | The integer to subtract. |
Returns
A reactive Maths.Integer, loading until its operands settle.
Example
const left = Maths.Integer.Subtract(10, 3);Maths.Integer.ToString
Turns an integer into text, so it can be shown with Content.Text.
Parameters
| Name | Type | Description |
|---|---|---|
value | Maths.Integer | The integer to stringify. |
Returns
A reactive Text.
Example
const count = Maths.Integer.Add(1, 1);
Content.Text(Maths.Integer.ToString(count));Maths.Real.Add
Adds two real numbers.
Parameters
| Name | Type | Description |
|---|---|---|
a | Maths.Real | The first number. |
b | Maths.Real | The second number. |
Returns
A reactive Maths.Real, loading until its operands settle.
Example
const sum = Maths.Real.Add(1.5, 2.25);Maths.Real.Divide
Divides one real number by another, keeping the fractional part.
Parameters
| Name | Type | Description |
|---|---|---|
a | Maths.Real | The dividend. |
b | Maths.Real | The divisor. |
Returns
A reactive Maths.Real; the result keeps the float.
Example
const ratio = Maths.Real.Divide(7, 2);Maths.Real.Multiply
Multiplies two real numbers.
Parameters
| Name | Type | Description |
|---|---|---|
a | Maths.Real | The first number. |
b | Maths.Real | The second number. |
Returns
A reactive Maths.Real, loading until its operands settle.
Example
const area = Maths.Real.Multiply(2.5, 4);Maths.Real.Subtract
Subtracts one real number from another.
Parameters
| Name | Type | Description |
|---|---|---|
a | Maths.Real | The number to subtract from. |
b | Maths.Real | The number to subtract. |
Returns
A reactive Maths.Real, loading until its operands settle.
Example
const left = Maths.Real.Subtract(5.0, 1.5);Maths.Real.ToString
Turns a real number into text, so it can be shown with Content.Text.
Parameters
| Name | Type | Description |
|---|---|---|
value | Maths.Real | The number to stringify. |
Returns
A reactive Text.
Example
const sum = Maths.Real.Add(1.5, 2.25);
Content.Text(Maths.Real.ToString(sum));