Skip to main content

Class: NumberUnitReadOnly<F, U>

A read-only interface for a WT_NumberUnit.

Type parameters

NameType
Fextends string
Uextends Unit<F> = Unit<F>

Implements

Constructors

constructor

new NumberUnitReadOnly<F, U>(source): NumberUnitReadOnly<F, U>

Constructor.

Type parameters

NameType
Fextends string
Uextends Unit<F> = Unit<F>

Parameters

NameTypeDescription
sourceNumberUnit<F, U>the source of the new read-only NumberUnit.

Returns

NumberUnitReadOnly<F, U>

Defined in

src/sdk/math/NumberUnit.ts:490

Accessors

number

get number(): number

Gets this NumberUnit's numeric value.

Returns

number

This NumberUnit's numeric value.

Implementation of

NumberUnitInterface.number

Defined in

src/sdk/math/NumberUnit.ts:497


unit

get unit(): U

Gets this NumberUnit's unit type.

Returns

U

This NumberUnit's unit type.

Implementation of

NumberUnitInterface.unit

Defined in

src/sdk/math/NumberUnit.ts:505

Methods

abs

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

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

Type parameters

NameType
OUextends Unit<F>

Parameters

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

Returns

NumberUnit<F, OU>

The absolute value.

Implementation of

NumberUnitInterface.abs

Defined in

src/sdk/math/NumberUnit.ts:606


add

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

Adds a value to this NumberUnit and returns the result.

Type parameters

NameType
OUextends Unit<F>

Parameters

NameTypeDescription
valueNumberUnitInterface<F, Unit<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.

Implementation of

NumberUnitInterface.add

Defined in

src/sdk/math/NumberUnit.ts:516

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

Adds a value to this NumberUnit and returns the result.

Type parameters

NameType
OUextends Unit<F>

Parameters

NameTypeDescription
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.

Implementation of

NumberUnitInterface.add

Defined in

src/sdk/math/NumberUnit.ts:525


asUnit

asUnit(unit): number

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

Parameters

NameTypeDescription
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.

Implementation of

NumberUnitInterface.asUnit

Defined in

src/sdk/math/NumberUnit.ts:616


compare

compare(value): number

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

Parameters

NameTypeDescription
valueNumberUnitInterface<F, Unit<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.

Implementation of

NumberUnitInterface.compare

Defined in

src/sdk/math/NumberUnit.ts:626

compare(value, unit?): number

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

Parameters

NameTypeDescription
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.

Implementation of

NumberUnitInterface.compare

Defined in

src/sdk/math/NumberUnit.ts:634


copy

copy(): NumberUnit<F, U>

Copies this NumberUnit.

Returns

NumberUnit<F, U>

A copy of this NumberUnit.

Implementation of

NumberUnitInterface.copy

Defined in

src/sdk/math/NumberUnit.ts:682


equals

equals(value): boolean

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

NameTypeDescription
valueNumberUnitInterface<string, Unit<string>>The other value.

Returns

boolean

Whether this NumberUnit is equal to the other value.

Implementation of

NumberUnitInterface.equals

Defined in

src/sdk/math/NumberUnit.ts:651

equals(value, unit?): boolean

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

NameTypeDescription
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.

Implementation of

NumberUnitInterface.equals

Defined in

src/sdk/math/NumberUnit.ts:660


isNaN

isNaN(): boolean

Checks whether this NumberUnit has a numeric value of NaN.

Returns

boolean

Whether this NumberUnit has a numeric value of NaN.

Implementation of

NumberUnitInterface.isNaN

Defined in

src/sdk/math/NumberUnit.ts:674


ratio

ratio(value): number

Finds the ratio of this NumberUnit to another value.

Parameters

NameTypeDescription
valueNumberUnitInterface<F, Unit<F>>The other value.

Returns

number

The ratio.

Throws

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

Implementation of

NumberUnitInterface.ratio

Defined in

src/sdk/math/NumberUnit.ts:583

ratio(value, unit): number

Finds the ratio of this NumberUnit to another value.

Parameters

NameTypeDescription
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.

Implementation of

NumberUnitInterface.ratio

Defined in

src/sdk/math/NumberUnit.ts:591


scale

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

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

Type parameters

NameType
OUextends Unit<F>

Parameters

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

Returns

NumberUnit<F, OU>

The scaled value.

Implementation of

NumberUnitInterface.scale

Defined in

src/sdk/math/NumberUnit.ts:573


subtract

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

Subtracts a value from this NumberUnit and returns the result.

Type parameters

NameType
OUextends Unit<F>

Parameters

NameTypeDescription
valueNumberUnitInterface<F, Unit<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.

Implementation of

NumberUnitInterface.subtract

Defined in

src/sdk/math/NumberUnit.ts:545

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

Subtracts a value from this NumberUnit and returns the result.

Type parameters

NameType
OUextends Unit<F>

Parameters

NameTypeDescription
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.

Implementation of

NumberUnitInterface.subtract

Defined in

src/sdk/math/NumberUnit.ts:554