Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "float"

Index

Variables

Functions

Variables

Const float

float: function = memoizeJ((prec) => (x: number) => nanOrInf(x) || x.toFixed(prec))

Returns Stringer which formats numbers to given precision. Exceptions:

  • NaN => "NaN"
  • Infinity => "+/-∞"
param

number of fractional digits

kind

function

Type declaration

    • Parameters

      • prec: number

      Returns Stringer<number>

Const floatFixedWidth

floatFixedWidth: function = memoizeJ((width, prec = 3) => {const l = width - prec - 1;const pl = Math.pow(10, l);const pln = -Math.pow(10, l - 1);const pr = Math.pow(10, -(prec - 1));const pad = padLeft(width);return (x: number) => {const ax = Math.abs(x);return pad(nanOrInf(x) ||(x === 0? "0": ax < pr || ax >= pl? exp(x, width): x.toFixed(prec - (x < pln ? 1 : 0))));};})

Similar to float, returns Stringer which formats numbers to given character width & precision. Uses scientific notation if needed.

Default precision: 3 fractional digits

Type declaration

    • (width: number, prec?: number): Stringer<number>
    • Parameters

      • width: number
      • Optional prec: number

      Returns Stringer<number>

Functions

Const exp

  • exp(x: number, w: number): string
  • Parameters

    • x: number
    • w: number

    Returns string

Const nanOrInf

  • nanOrInf(x: number): "NaN" | "+∞" | "-∞"
  • Parameters

    • x: number

    Returns "NaN" | "+∞" | "-∞"

Generated using TypeDoc