Skip to main content

Interface: NumberUnitInterface<F, U>

Defined in: src/sdk/math/NumberUnit.ts:16

A numeric value with unit type.

Type Parameters

Type ParameterDefault type
F extends string-
U extends Unit<F>Unit<F>

Properties

number

number: number

Defined in: src/sdk/math/NumberUnit.ts:18

This NumberUnit's numeric value.


unit

unit: U

Defined in: src/sdk/math/NumberUnit.ts:21

This NumberUnit's unit type.

Methods

abs()

abs<OU>(out): NumberUnit<F, OU>

Defined in: src/sdk/math/NumberUnit.ts:88

Calculates the absolute value of this NumberUnit and returns the result.

Type Parameters

Type Parameter
OU extends Unit<F>

Parameters

ParameterTypeDescription
outNumberUnit<F, OU>The NumberUnit to which to write the result.

Returns

NumberUnit<F, OU>

The absolute value.


add()

Call Signature

add<OU>(value, out): NumberUnit<F, OU>

Defined in: src/sdk/math/NumberUnit.ts:30

Adds a value to this NumberUnit and returns the result.

Type Parameters
Type Parameter
OU extends Unit<F>
Parameters
ParameterTypeDescription
valueNumberUnitInterface<F>The other value.
outNumberUnit<F, OU>The NumberUnit to which to write the result.
Returns

NumberUnit<F, OU>

The sum.

Throws

Error if the supplied value cannot be converted to this NumberUnit's unit type.

Call Signature

add<OU>(value, unit, out): NumberUnit<F, OU>

Defined in: src/sdk/math/NumberUnit.ts:39

Adds a value to this NumberUnit and returns the result.

Type Parameters
Type Parameter
OU extends Unit<F>
Parameters
ParameterTypeDescription
valuenumberThe other value.
unitUnit<F>The unit type of the other value.
outNumberUnit<F, OU>The NumberUnit to which to write the result.
Returns

NumberUnit<F, OU>

The sum.

Throws

Error if the supplied value cannot be converted to this NumberUnit's unit type.


asUnit()

asUnit(unit): number

Defined in: src/sdk/math/NumberUnit.ts:96

Returns the numeric value of this NumberUnit after conversion to a specified unit.

Parameters

ParameterTypeDescription
unitUnit<F>The unit to which to convert.

Returns

number

The converted numeric value.

Throws

Error if this NumberUnit's unit type cannot be converted to the specified unit.


compare()

Call Signature

compare(value): number

Defined in: src/sdk/math/NumberUnit.ts:104

Checks whether this NumberUnit is greater than, equal to, or less than another value.

Parameters
ParameterTypeDescription
valueNumberUnitInterface<F>The other value.
Returns

number

0 if this NumberUnit is equal to the other value, -1 if this number is less, 1 if this number is greater.

Throws

Error if this NumberUnit cannot be compared to the other value.

Call Signature

compare(value, unit?): number

Defined in: src/sdk/math/NumberUnit.ts:112

Checks whether this NumberUnit is greater than, equal to, or less than another value.

Parameters
ParameterTypeDescription
valuenumberThe other value.
unit?Unit<F>The unit type of the other value. Defaults to this NumberUnit's unit type.
Returns

number

0 if this NumberUnit is equal to the other value, -1 if this number is less, 1 if this number is greater.

Throws

Error if this NumberUnit cannot be compared to the other value.


copy()

copy(): NumberUnit<F, U>

Defined in: src/sdk/math/NumberUnit.ts:142

Copies this NumberUnit.

Returns

NumberUnit<F, U>

A copy of this NumberUnit.


equals()

Call Signature

equals(value): boolean

Defined in: src/sdk/math/NumberUnit.ts:121

Checks whether this NumberUnit is equal to another value. Two values are considered equal if and only if their unit types are interconvertable and when converted to the same unit type, their numeric values are equal to each other or both equal to NaN.

Parameters
ParameterTypeDescription
valueNumberUnitInterface<string>The other value.
Returns

boolean

Whether this NumberUnit is equal to the other value.

Call Signature

equals(value, unit?): boolean

Defined in: src/sdk/math/NumberUnit.ts:130

Checks whether this NumberUnit is equal to another value. Two values are considered equal if and only if their unit types are interconvertable and when converted to the same unit type, their numeric values are equal to each other or both equal to NaN.

Parameters
ParameterTypeDescription
valuenumberThe other value.
unit?Unit<string>The unit type of the other value. Defaults to this NumberUnit's unit type.
Returns

boolean

Whether this NumberUnit is equal to the other value.


isNaN()

isNaN(): boolean

Defined in: src/sdk/math/NumberUnit.ts:136

Checks whether this NumberUnit has a numeric value of NaN.

Returns

boolean

Whether this NumberUnit has a numeric value of NaN.


ratio()

Call Signature

ratio(value): number

Defined in: src/sdk/math/NumberUnit.ts:73

Finds the ratio of this NumberUnit to another value.

Parameters
ParameterTypeDescription
valueNumberUnitInterface<F>The other value.
Returns

number

The ratio.

Throws

Error if the other value cannot be converted to this NumberUnit's unit type.

Call Signature

ratio(value, unit): number

Defined in: src/sdk/math/NumberUnit.ts:81

Finds the ratio of this NumberUnit to another value.

Parameters
ParameterTypeDescription
valuenumberThe other value.
unitUnit<F>The unit type of the other value.
Returns

number

the ratio.

Throws

Error if the other value cannot be converted to this NumberUnit's unit type.


scale()

scale<OU>(factor, out): NumberUnit<F, OU>

Defined in: src/sdk/math/NumberUnit.ts:65

Scales this NumberUnit by a unit-less factor and returns the result.

Type Parameters

Type Parameter
OU extends Unit<F>

Parameters

ParameterTypeDescription
factornumberThe factor by which to scale.
outNumberUnit<F, OU>The NumberUnit to which to write the result.

Returns

NumberUnit<F, OU>

The scaled value.


subtract()

Call Signature

subtract<OU>(value, out): NumberUnit<F, OU>

Defined in: src/sdk/math/NumberUnit.ts:48

Subtracts a value from this NumberUnit and returns the result.

Type Parameters
Type Parameter
OU extends Unit<F>
Parameters
ParameterTypeDescription
valueNumberUnitInterface<F>The other value.
outNumberUnit<F, OU>The NumberUnit to which to write the result.
Returns

NumberUnit<F, OU>

The difference.

Throws

Error if the supplied value cannot be converted to this NumberUnit's unit type.

Call Signature

subtract<OU>(value, unit, out): NumberUnit<F, OU>

Defined in: src/sdk/math/NumberUnit.ts:57

Subtracts a value from this NumberUnit and returns the result.

Type Parameters
Type Parameter
OU extends Unit<F>
Parameters
ParameterTypeDescription
valuenumberThe other value.
unitUnit<F>The unit type of the other value.
outNumberUnit<F, OU>The NumberUnit to which to write the result.
Returns

NumberUnit<F, OU>

The difference.

Throws

Error if the supplied value cannot be converted to this NumberUnit's unit type.