Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UnitValue<U>

Unit value

Usage

Creation

const value = new UnitValue(5, LengthUnit.METER);

Conversion

const value = new UnitValue(5, LengthUnit.METER);
const converted = value.to(LengthUnit.CENTIMETER);

Type parameters

Hierarchy

  • UnitValue

Implements

  • Number

Index

Constructors

constructor

  • new UnitValue<U>(value: number, unit: U): UnitValue<U>

Accessors

unit

  • get unit(): U

Methods

to

toExponential

  • toExponential(fractionDigits?: number): string
  • Returns a string containing a number represented in exponential notation.

    Parameters

    • Optional fractionDigits: number

      of digits after the decimal point. Must be in the range 0 - 20, inclusive.

    Returns string

    Exponential string

toFixed

  • toFixed(fractionDigits?: number): string
  • Returns a string representing a number in fixed-point notation.

    Parameters

    • Optional fractionDigits: number

      of digits after the decimal point. Must be in the range 0 - 20, inclusive.

    Returns string

    Fixed number

toPrecision

  • toPrecision(precision?: number): string
  • Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits.

    Parameters

    • Optional precision: number

      Number of significant digits. Must be in the range 1 - 21, inclusive.

    Returns string

    Precision string

toString

  • toString(radix?: number): string
  • Returns a string representation of an object.

    Parameters

    • Optional radix: number

      specifies a radix for converting numeric values to strings. This value is only used for numbers.

    Returns string

    Unit value as string

valueOf

  • valueOf(): number