Skip to content

BinaryFp128

Defined in: packages/math-numbers/src/num/binary-fp128.ts:38

IEEE 754 binary128 (quadruple-precision) floating-point number.

Backed by a BinaryFp instance configured with IEEE_FORMAT_BINARY128. This provides a clean API with the correct numeric type, while the actual arithmetic precision is currently limited to binary64 (JS number) until the bigint-backed BinaryFp implementation is complete.

References:

  • BinaryFpBase<BinaryFp128>

new BinaryFp128(value): BinaryFp128

Defined in: packages/math-numbers/src/num/binary-fp128.ts:89

Creates a BinaryFp128 value.

Accepts either a raw number | string (converted to binary128 soft-float) or an existing BinaryFp instance (used internally when wrapping arithmetic results).

string | number | BinaryFp

Initial value or backing soft-float.

BinaryFp128

When a BinaryFp is passed whose format is not IEEE_FORMAT_BINARY128 — guards against accidentally constructing a BinaryFp128 backed by a binary64 engine.

BinaryFpBase<BinaryFp128>.constructor

readonly static IEEE754: IeeeFormat = IEEE_FORMAT_BINARY128

Defined in: packages/math-numbers/src/num/binary-fp128.ts:53

IEEE 754-2008 structural parameters for binary128. b=2, k=128, p=113, emax=16383.


readonly static INFINITY: BinaryFp128

Defined in: packages/math-numbers/src/num/binary-fp128.ts:66

IEEE 754 positive infinity.


readonly static NAN: BinaryFp128

Defined in: packages/math-numbers/src/num/binary-fp128.ts:64

IEEE 754 Not-a-Number.


readonly static NEG_INFINITY: BinaryFp128

Defined in: packages/math-numbers/src/num/binary-fp128.ts:68

IEEE 754 negative infinity.


readonly static ONE: BinaryFp128

Defined in: packages/math-numbers/src/num/binary-fp128.ts:58

Multiplicative identity 1.0q.


readonly static STRUCTURE: AlgebraicStructure = APPROXIMATE_ORDERED_FIELD

Defined in: packages/math-numbers/src/num/_binary-fp-base.ts:41

Binary floating point is not a field: every operation rounds, so associativity and distributivity fail.

BinaryFpBase.STRUCTURE


readonly static TAG: typeof TAG

Defined in: packages/math-numbers/src/num/binary-fp128.ts:47

Unique type tag used by the converter registry.


readonly static TEN: BinaryFp128

Defined in: packages/math-numbers/src/num/binary-fp128.ts:62

The value 10.0q.


readonly static TWO: BinaryFp128

Defined in: packages/math-numbers/src/num/binary-fp128.ts:60

The value 2.0q.


readonly static ZERO: BinaryFp128

Defined in: packages/math-numbers/src/num/binary-fp128.ts:56

Additive identity 0.0q.

get bitWidth(): 128

Defined in: packages/math-numbers/src/num/binary-fp128.ts:42

Total width of the representation, in bits.

128

Total width of the representation, in bits.

IFixedPrecision.bitWidth

BinaryFpBase.bitWidth


get decimalPrecision(): number

Defined in: packages/math-numbers/src/num/binary-fp128.ts:180

Number of significant decimal digits (~33 for binary128, currently limited to ~15 while backed by binary64).

number

Total number of significant decimal digits needed to exactly represent this value.

Returns Number.POSITIVE_INFINITY for values with non-terminating decimal expansions (e.g. Fraction(1, 3), √2).

Integer.from(12345n).decimalPrecision; // → 5
Decimal.from("3.14").decimalPrecision; // → 3
Fraction.from(1n, 3n).decimalPrecision; // → Infinity
```;
#### Implementation of
[`INum`](../interfaces/INum.md).[`decimalPrecision`](../interfaces/INum.md#decimalprecision)
#### Overrides
`BinaryFpBase.decimalPrecision`
***
### formatInfo
#### Get Signature
> **get** **formatInfo**(): [`FixedPrecisionInfo`](../type-aliases/FixedPrecisionInfo.md)\<`BinaryFp128`\>
Defined in: packages/math-numbers/src/num/binary-fp128.ts:293
Fixed-precision format descriptor for IEEE 754 binary128.
Note: `minPositive`/`maxPositive` are currently approximated with binary64
values. These will be corrected when bigint-backed `BinaryFp` is
available.
##### Returns
[`FixedPrecisionInfo`](../type-aliases/FixedPrecisionInfo.md)\<`BinaryFp128`\>
#### Overrides
`BinaryFpBase.formatInfo`
***
### fractionalPrecision
#### Get Signature
> **get** **fractionalPrecision**(): `number`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:190
Number of decimal digits in the fractional part.
##### Returns
`number`
Number of decimal digits in the fractional part of `|value|`. `0` for exact
integers. Returns `Number.POSITIVE_INFINITY` for non-terminating decimal
expansions.
#### Example
```ts
Integer.from(42n).fractionalPrecision; // → 0
Decimal.from("3.14").fractionalPrecision; // → 2
Fraction.from(1n, 3n).fractionalPrecision; // → Infinity
```;
#### Implementation of
[`INum`](../interfaces/INum.md).[`fractionalPrecision`](../interfaces/INum.md#fractionalprecision)
#### Overrides
`BinaryFpBase.fractionalPrecision`
***
### integralPrecision
#### Get Signature
> **get** **integralPrecision**(): `number`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:185
Number of decimal digits in the integer part.
##### Returns
`number`
Number of decimal digits in the integer (integral) part of `|value|`.
Always at least `1` (the digit `0` for values with `|value| < 1`).
#### Example
```ts
Integer.from(123n).integralPrecision; // → 3
Decimal.from("0.5").integralPrecision; // → 1 (the leading '0')
Decimal.from("3.14").integralPrecision; // → 1
```;
#### Implementation of
[`INum`](../interfaces/INum.md).[`integralPrecision`](../interfaces/INum.md#integralprecision)
#### Overrides
`BinaryFpBase.integralPrecision`
***
### isFinite
#### Get Signature
> **get** **isFinite**(): `boolean`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:119
`true` if this value is finite (not NaN and not ±∞).
##### Returns
`boolean`
***
### isInfinite
#### Get Signature
> **get** **isInfinite**(): `boolean`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:124
`true` if this value is +∞ or −∞.
##### Returns
`boolean`
***
### isNaN
#### Get Signature
> **get** **isNaN**(): `boolean`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:114
`true` if this value is IEEE 754 NaN.
##### Returns
`boolean`
***
### precisionKind
#### Get Signature
> **get** **precisionKind**(): `"fixed"`
Defined in: packages/math-numbers/src/num/\_binary-fp-base.ts:30
##### Returns
`"fixed"`
#### Implementation of
[`IFixedPrecision`](../interfaces/IFixedPrecision.md).[`precisionKind`](../interfaces/IFixedPrecision.md#precisionkind)
#### Inherited from
`BinaryFpBase.precisionKind`
***
### radix
#### Get Signature
> **get** **radix**(): `2`
Defined in: packages/math-numbers/src/num/\_binary-fp-base.ts:33
##### Returns
`2`
#### Implementation of
[`IBinaryEncoded`](../interfaces/IBinaryEncoded.md).[`radix`](../interfaces/IBinaryEncoded.md#radix)
#### Inherited from
`BinaryFpBase.radix`
## Methods
### \[toPrimitive\]()
> **\[toPrimitive\]**(`hint`): `string` \| `number` \| `bigint`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:165
Coerces to a JS primitive.
#### Parameters
##### hint
`"string"` \| `"number"` \| `"default"`
#### Returns
`string` \| `number` \| `bigint`
#### Implementation of
[`INum`](../interfaces/INum.md).[`[toPrimitive]`](../interfaces/INum.md#toprimitive)
#### Overrides
`BinaryFpBase.[toPrimitive]`
***
### abs()
> **abs**(): `BinaryFp128`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:264
Absolute value `|x|`.
#### Returns
`BinaryFp128`
#### Overrides
`BinaryFpBase.abs`
***
### add()
> **add**(`other`): `BinaryFp128`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:213
Returns `this + other`.
#### Parameters
##### other
`BinaryFp128`
#### Returns
`BinaryFp128`
#### Overrides
`BinaryFpBase.add`
***
### bitAt()
> **bitAt**(`position`): `0` \| `1`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:314
Returns the bit at `position` in the packed binary128 bit pattern. Position
`0` is the LSB; position `127` is the sign bit.
#### Parameters
##### position
`number`
#### Returns
`0` \| `1`
#### Throws
When `position` is outside `[0, 127]`.
#### Overrides
`BinaryFpBase.bitAt`
***
### clamp()
> **clamp**(`lower`, `upper`): `BinaryFp128`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:69
Restricts the value to `[lower, upper]`.
#### Parameters
##### lower
`BinaryFp128`
##### upper
`BinaryFp128`
#### Returns
`BinaryFp128`
#### Inherited from
`BinaryFpBase.clamp`
***
### cmp()
> **cmp**(`other`): `Sign`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:255
Three-way comparison.
#### Parameters
##### other
`BinaryFp128`
#### Returns
`Sign`
#### Throws
When either value is NaN.
#### Overrides
`BinaryFpBase.cmp`
***
### div()
> **div**(`other`): `BinaryFp128`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:242
Returns `this / other` (IEEE 754 semantics).
#### Parameters
##### other
`BinaryFp128`
#### Returns
`BinaryFp128`
#### Overrides
`BinaryFpBase.div`
***
### eq()
> **eq**(`other`): `boolean`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:45
#### Parameters
##### other
`BinaryFp128`
#### Returns
`boolean`
#### Inherited from
`BinaryFpBase.eq`
***
### format()
> **format**(`locales?`, `options?`): `string`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:149
This value rendered for a human, by `Intl.NumberFormat`.
The parameters are `new Intl.NumberFormat(locales, options)`'s own,
unchanged — including the default, which is the ambient locale. Ask for
`"en-US"` with `useGrouping: false` when the output has to be
machine-readable.
#### Parameters
##### locales?
`LocalesArgument`
##### options?
`NumberFormatOptions`
#### Returns
`string`
#### Implementation of
[`INum`](../interfaces/INum.md).[`format`](../interfaces/INum.md#format)
#### Overrides
`BinaryFpBase.format`
***
### gt()
> **gt**(`other`): `boolean`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:57
#### Parameters
##### other
`BinaryFp128`
#### Returns
`boolean`
#### Inherited from
`BinaryFpBase.gt`
***
### gte()
> **gte**(`other`): `boolean`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:73
#### Parameters
##### other
`BinaryFp128`
#### Returns
`boolean`
#### Inherited from
`BinaryFpBase.gte`
***
### identity()
> **identity**(): `BinaryFp128`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:204
Returns the multiplicative identity `1.0q`.
#### Returns
`BinaryFp128`
#### Overrides
`BinaryFpBase.identity`
***
### inv()
> **inv**(): `BinaryFp128`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:237
Returns `1 / this`. Returns ±∞ for zero (IEEE 754 semantics).
#### Returns
`BinaryFp128`
#### Overrides
`BinaryFpBase.inv`
***
### lt()
> **lt**(`other`): `boolean`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:49
#### Parameters
##### other
`BinaryFp128`
#### Returns
`boolean`
#### Inherited from
`BinaryFpBase.lt`
***
### lte()
> **lte**(`other`): `boolean`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:53
#### Parameters
##### other
`BinaryFp128`
#### Returns
`boolean`
#### Inherited from
`BinaryFpBase.lte`
***
### max()
> **max**(`other`): `BinaryFp128`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:65
The larger of the two operands under the total order.
#### Parameters
##### other
`BinaryFp128`
#### Returns
`BinaryFp128`
#### Inherited from
`BinaryFpBase.max`
***
### min()
> **min**(`other`): `BinaryFp128`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:61
The smaller of the two operands under the total order.
#### Parameters
##### other
`BinaryFp128`
#### Returns
`BinaryFp128`
#### Inherited from
`BinaryFpBase.min`
***
### mul()
> **mul**(`other`): `BinaryFp128`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:199
Returns `this × other`.
#### Parameters
##### other
`BinaryFp128`
#### Returns
`BinaryFp128`
#### Overrides
`BinaryFpBase.mul`
***
### neg()
> **neg**(): `BinaryFp128`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:223
Returns `−this`.
#### Returns
`BinaryFp128`
#### Overrides
`BinaryFpBase.neg`
***
### sign()
> **sign**(): `Sign`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:273
Sign of this value.
#### Returns
`Sign`
`-1` for negative, `0` for zero/NaN, `+1` for positive.
#### Overrides
`BinaryFpBase.sign`
***
### sqrt()
> **sqrt**(): `BinaryFp128`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:278
Principal square root `√x`. Returns `NaN` for negative inputs.
#### Returns
`BinaryFp128`
#### Overrides
`BinaryFpBase.sqrt`
***
### sub()
> **sub**(`other`): `BinaryFp128`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:228
Returns `this − other`.
#### Parameters
##### other
`BinaryFp128`
#### Returns
`BinaryFp128`
#### Overrides
`BinaryFpBase.sub`
***
### toExponential()
> **toExponential**(`fractionDigits?`): `string`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:141
Exponential notation: one digit before the point, `fractionDigits` after,
and an `e±` exponent. Omitting the count shows as many as the value has,
matching `Number.prototype.toExponential`.
#### Parameters
##### fractionDigits?
`number`
#### Returns
`string`
#### Implementation of
[`INum`](../interfaces/INum.md).[`toExponential`](../interfaces/INum.md#toexponential)
#### Overrides
`BinaryFpBase.toExponential`
***
### toFixed()
> **toFixed**(`fractionDigits?`): `string`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:137
Fixed-point notation with exactly `fractionDigits` places, padded with
zeros where the value has fewer — `Number.prototype.toFixed`, without its
cap of 100. A type that can hold more places can show them.
#### Parameters
##### fractionDigits?
`number` = `0`
#### Returns
`string`
#### Implementation of
[`INum`](../interfaces/INum.md).[`toFixed`](../interfaces/INum.md#tofixed)
#### Overrides
`BinaryFpBase.toFixed`
***
### toPrecision()
> **toPrecision**(`precision`): `string`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:145
`precision` significant digits, switching to exponential notation at the
same thresholds `Number.prototype.toPrecision` does.
#### Parameters
##### precision
`number`
#### Returns
`string`
#### Implementation of
[`INum`](../interfaces/INum.md).[`toPrecision`](../interfaces/INum.md#toprecision)
#### Overrides
`BinaryFpBase.toPrecision`
***
### toString()
> **toString**(`radix?`): `string`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:133
The exact expansion, since no engine format can hold a binary128.
#### Parameters
##### radix?
`number`
#### Returns
`string`
#### Implementation of
[`INum`](../interfaces/INum.md).[`toString`](../interfaces/INum.md#tostring)
#### Overrides
`BinaryFpBase.toString`
***
### valueOf()
> **valueOf**(): `number`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:160
Returns the value as a JS `number` (binary64 approximation). Precision
beyond ~15 significant decimal digits is lost.
#### Returns
`number`
#### Implementation of
[`INum`](../interfaces/INum.md).[`valueOf`](../interfaces/INum.md#valueof)
#### Overrides
`BinaryFpBase.valueOf`
***
### zero()
> **zero**(): `BinaryFp128`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:218
Returns the additive identity `0.0q`.
#### Returns
`BinaryFp128`
#### Overrides
`BinaryFpBase.zero`
***
### from()
> `static` **from**(`value`): `BinaryFp128`
Defined in: packages/math-numbers/src/num/binary-fp128.ts:105
Creates a `BinaryFp128` from a `number` or parseable numeric string.
#### Parameters
##### value
`string` \| `number`
#### Returns
`BinaryFp128`