Qnum
Defined in: src/dataframe/qnum.ts:30
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
Constructor
new Qnum():
Qnum
Returns
Qnum
Methods
create()
staticcreate(value,q?):number
Defined in: src/dataframe/qnum.ts:54
Creates a QNum value out of the [value] and qualifier [q].
Parameters
| Parameter | Type | Default value |
|---|---|---|
value | number | undefined |
q | number | QNUM_EXACT |
Returns
number
exact()
staticexact(x):number
Defined in: src/dataframe/qnum.ts:61
Parameters
| Parameter | Type |
|---|---|
x | number |
Returns
number
getQ()
staticgetQ(x):number
Defined in: src/dataframe/qnum.ts:35
Extracts the qualifier (QNUM_LESS, QNUM_EXACT, QNUM_GREATER). See also getValue
Parameters
| Parameter | Type |
|---|---|
x | number |
Returns
number
getValue()
staticgetValue(x):number
Defined in: src/dataframe/qnum.ts:44
Extracts the value from x, stripping the qualifier . See also getQ
Parameters
| Parameter | Type |
|---|---|
x | number |
Returns
number
greater()
staticgreater(x):number
Defined in: src/dataframe/qnum.ts:69
Parameters
| Parameter | Type |
|---|---|
x | number |
Returns
number
less()
staticless(x):number
Defined in: src/dataframe/qnum.ts:65
Parameters
| Parameter | Type |
|---|---|
x | number |
Returns
number
parse()
staticparse(s):number
Defined in: src/dataframe/qnum.ts:76
Parses a string into a qualified number.
Parameters
| Parameter | Type |
|---|---|
s | string |
Returns
number
qualifier()
staticqualifier(x):string
Defined in: src/dataframe/qnum.ts:90
Returns the string representation of the qualifier.
Parameters
| Parameter | Type |
|---|---|
x | number |
Returns
string
toString()
statictoString(x):string
Defined in: src/dataframe/qnum.ts:83
Converts a qualified number to a string representation.
Parameters
| Parameter | Type |
|---|---|
x | number |
Returns
string