Skip to main content

Qnum

A set of static methods for working with qualified numbers. The internal representation of a qualified number is a regular double precision floating point number (IEEE 754), except the two least significant bits in mantissa are reserved for holding the qualifier ([LESS], [EXACT], [GREATER]).

The advantage of that representation is that the standard arithmetic operations could be performed directly on the number, without unpacking it. This is especially important for batch operations such as aggregation or sorting. While there is a loss of precision, it is rather insignificant (50 bits for storing mantissa instead of 52), which makes perfect sense considering that qualified numbers represent imprecise measurements.

Use [create], [getValue], and [getQ] methods for packing/unpacking.

Constructors

new Qnum()

new Qnum(): Qnum

Returns

Qnum

Methods

create()

static create(value, q): number

Creates a QNum value out of the [value] and qualifier [q].

Parameters

ParameterTypeDefault valueDescription
valuenumberundefined
qnumberQNUM_EXACT

Returns

number

Source

src/dataframe.ts:2259


exact()

static exact(x): number

Parameters

ParameterType
xnumber

Returns

number

Source

src/dataframe.ts:2266


getQ()

static getQ(x): number

Extracts the qualifier (QNUM_LESS, QNUM_EXACT, QNUM_GREATER). See also getValue

Parameters

ParameterTypeDescription
xnumber

Returns

number

Source

src/dataframe.ts:2235


getValue()

static getValue(x): number

Extracts the value from x, stripping the qualifier . See also getQ

Parameters

ParameterTypeDescription
xnumber

Returns

number

Source

src/dataframe.ts:2246


greater()

static greater(x): number

Parameters

ParameterType
xnumber

Returns

number

Source

src/dataframe.ts:2274


less()

static less(x): number

Parameters

ParameterType
xnumber

Returns

number

Source

src/dataframe.ts:2270


parse()

static parse(s): number

Parses a string into a qualified number.

Parameters

ParameterTypeDescription
sstring

Returns

number

Source

src/dataframe.ts:2283


qualifier()

static qualifier(x): string

Returns the string representation of the qualifier.

Parameters

ParameterTypeDescription
xnumber

Returns

string

Source

src/dataframe.ts:2301


toString()

static toString(x): string

Converts a qualified number to a string representation.

Parameters

ParameterTypeDescription
xnumber

Returns

string

Source

src/dataframe.ts:2292