BinaryFp16
Defined in: packages/math-numbers/src/num/binary-fp16.ts:44
IEEE 754 binary16 (half-precision) floating-point number.
Backed by a JS number; each operation rounds the result to half precision
using round-to-nearest-even before storing it.
Range: ≈ ±65504; precision: ~3–4 significant decimal digits.
References:
- IEEE 754-2019: https://en.wikipedia.org/wiki/IEEE_754
- Half precision: https://en.wikipedia.org/wiki/Half-precision_floating-point_format
Extends
Section titled “Extends”BinaryFpBase<BinaryFp16>
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BinaryFp16(
value):BinaryFp16
Defined in: packages/math-numbers/src/num/binary-fp16.ts:84
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”BinaryFp16
Overrides
Section titled “Overrides”BinaryFpBase<BinaryFp16>.constructor
Properties
Section titled “Properties”IEEE754
Section titled “IEEE754”
readonlystaticIEEE754:IeeeFormat=IEEE_FORMAT_BINARY16
Defined in: packages/math-numbers/src/num/binary-fp16.ts:59
IEEE 754-2008 structural parameters for binary16. b=2, k=16, p=11,
emax=15.
INFINITY
Section titled “INFINITY”
readonlystaticINFINITY:BinaryFp16
Defined in: packages/math-numbers/src/num/binary-fp16.ts:72
IEEE 754 positive infinity.
MAX_VALUE
Section titled “MAX_VALUE”
readonlystaticMAX_VALUE:BinaryFp16
Defined in: packages/math-numbers/src/num/binary-fp16.ts:77
Max finite positive float16 (65504).
MIN_VALUE
Section titled “MIN_VALUE”
readonlystaticMIN_VALUE:BinaryFp16
Defined in: packages/math-numbers/src/num/binary-fp16.ts:79
Min positive normalised float16 (2^−14 ≈ 6.1035e-5).
readonlystaticNAN:BinaryFp16
Defined in: packages/math-numbers/src/num/binary-fp16.ts:70
IEEE 754 Not-a-Number.
NEG_INFINITY
Section titled “NEG_INFINITY”
readonlystaticNEG_INFINITY:BinaryFp16
Defined in: packages/math-numbers/src/num/binary-fp16.ts:74
IEEE 754 negative infinity.
readonlystaticONE:BinaryFp16
Defined in: packages/math-numbers/src/num/binary-fp16.ts:64
Multiplicative identity 1.0h.
STRUCTURE
Section titled “STRUCTURE”
readonlystaticSTRUCTURE: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.
Inherited from
Section titled “Inherited from”BinaryFpBase.STRUCTURE
readonlystaticTAG: typeofTAG
Defined in: packages/math-numbers/src/num/binary-fp16.ts:53
Unique type tag used by the converter registry.
readonlystaticTEN:BinaryFp16
Defined in: packages/math-numbers/src/num/binary-fp16.ts:68
The value 10.0h.
readonlystaticTWO:BinaryFp16
Defined in: packages/math-numbers/src/num/binary-fp16.ts:66
The value 2.0h.
readonlystaticZERO:BinaryFp16
Defined in: packages/math-numbers/src/num/binary-fp16.ts:62
Additive identity 0.0h.
Accessors
Section titled “Accessors”bitWidth
Section titled “bitWidth”Get Signature
Section titled “Get Signature”get bitWidth():
16
Defined in: packages/math-numbers/src/num/binary-fp16.ts:48
Total width of the representation, in bits.
Returns
Section titled “Returns”16
Overrides
Section titled “Overrides”BinaryFpBase.bitWidth
decimalPrecision
Section titled “decimalPrecision”Get Signature
Section titled “Get Signature”get decimalPrecision():
number
Defined in: packages/math-numbers/src/num/binary-fp16.ts:172
Number of significant decimal digits (~3–4 for float16).
Returns
Section titled “Returns”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).
Example
Section titled “Example” 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)\<`BinaryFp16`\>
Defined in: packages/math-numbers/src/num/binary-fp16.ts:296
Fixed-precision format descriptor for IEEE 754 binary16.
##### Returns
[`FixedPrecisionInfo`](../type-aliases/FixedPrecisionInfo.md)\<`BinaryFp16`\>
#### Overrides
`BinaryFpBase.formatInfo`
***
### fractionalPrecision
#### Get Signature
> **get** **fractionalPrecision**(): `number`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:186
Number of decimal digits in the fractional part.
##### Returns
`number`
Number of decimal digits in the fractional part of `|value|`. `0` for exactintegers. Returns `Number.POSITIVE_INFINITY` for non-terminating decimalexpansions.
#### 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-fp16.ts:177
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-fp16.ts:113
`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-fp16.ts:118
`true` if this value is +∞ or −∞.
##### Returns
`boolean`
***
### isNaN
#### Get Signature
> **get** **isNaN**(): `boolean`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:108
`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"`
#### 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-fp16.ts:160
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**(): `BinaryFp16`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:268
Absolute value `|x|`.
#### Returns
`BinaryFp16`
#### Overrides
`BinaryFpBase.abs`
***
### add()
> **add**(`other`): `BinaryFp16`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:213
Returns `this + other`, rounded to float16.
#### Parameters
##### other
`BinaryFp16`
#### Returns
`BinaryFp16`
#### Overrides
`BinaryFpBase.add`
***
### bitAt()
> **bitAt**(`position`): `0` \| `1`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:316
Returns the bit at `position` in the IEEE 754 binary16 layout. Position `0`is the least-significant bit; position `15` is the sign bit.
#### Parameters
##### position
`number`
#### Returns
`0` \| `1`
#### Throws
When `position` is outside `[0, 15]`.
#### Overrides
`BinaryFpBase.bitAt`
***
### clamp()
> **clamp**(`lower`, `upper`): `BinaryFp16`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:69
Restricts the value to `[lower, upper]`.
#### Parameters
##### lower
`BinaryFp16`
##### upper
`BinaryFp16`
#### Returns
`BinaryFp16`
#### Inherited from
`BinaryFpBase.clamp`
***
### cmp()
> **cmp**(`other`): `Sign`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:255
Three-way comparison.
#### Parameters
##### other
`BinaryFp16`
#### Returns
`Sign`
#### Throws
When either value is NaN.
#### Overrides
`BinaryFpBase.cmp`
***
### div()
> **div**(`other`): `BinaryFp16`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:242
Returns `this / other`, rounded to float16.
#### Parameters
##### other
`BinaryFp16`
#### Returns
`BinaryFp16`
#### Overrides
`BinaryFpBase.div`
***
### eq()
> **eq**(`other`): `boolean`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:45
#### Parameters
##### other
`BinaryFp16`
#### Returns
`boolean`
#### Inherited from
`BinaryFpBase.eq`
***
### format()
> **format**(`locales?`, `options?`): `string`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:143
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 bemachine-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
`BinaryFp16`
#### Returns
`boolean`
#### Inherited from
`BinaryFpBase.gt`
***
### gte()
> **gte**(`other`): `boolean`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:73
#### Parameters
##### other
`BinaryFp16`
#### Returns
`boolean`
#### Inherited from
`BinaryFpBase.gte`
***
### identity()
> **identity**(): `BinaryFp16`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:204
Returns the multiplicative identity `1.0h`.
#### Returns
`BinaryFp16`
#### Overrides
`BinaryFpBase.identity`
***
### inv()
> **inv**(): `BinaryFp16`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:237
Returns `1 / this`, rounded to float16.
#### Returns
`BinaryFp16`
#### Overrides
`BinaryFpBase.inv`
***
### lt()
> **lt**(`other`): `boolean`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:49
#### Parameters
##### other
`BinaryFp16`
#### Returns
`boolean`
#### Inherited from
`BinaryFpBase.lt`
***
### lte()
> **lte**(`other`): `boolean`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:53
#### Parameters
##### other
`BinaryFp16`
#### Returns
`boolean`
#### Inherited from
`BinaryFpBase.lte`
***
### max()
> **max**(`other`): `BinaryFp16`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:65
The larger of the two operands under the total order.
#### Parameters
##### other
`BinaryFp16`
#### Returns
`BinaryFp16`
#### Inherited from
`BinaryFpBase.max`
***
### min()
> **min**(`other`): `BinaryFp16`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:61
The smaller of the two operands under the total order.
#### Parameters
##### other
`BinaryFp16`
#### Returns
`BinaryFp16`
#### Inherited from
`BinaryFpBase.min`
***
### mul()
> **mul**(`other`): `BinaryFp16`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:199
Returns `this × other`, rounded to float16.
#### Parameters
##### other
`BinaryFp16`
#### Returns
`BinaryFp16`
#### Overrides
`BinaryFpBase.mul`
***
### neg()
> **neg**(): `BinaryFp16`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:223
Returns `−this`.
#### Returns
`BinaryFp16`
#### Overrides
`BinaryFpBase.neg`
***
### sign()
> **sign**(): `Sign`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:277
Sign of this value.
#### Returns
`Sign`
`-1` for negative, `0` for zero/NaN, `+1` for positive.
#### Overrides
`BinaryFpBase.sign`
***
### sqrt()
> **sqrt**(): `BinaryFp16`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:287
Principal square root `√x`, rounded to float16. Returns `NaN` for negativeinputs.
#### Returns
`BinaryFp16`
#### Overrides
`BinaryFpBase.sqrt`
***
### sub()
> **sub**(`other`): `BinaryFp16`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:228
Returns `this − other`, rounded to float16.
#### Parameters
##### other
`BinaryFp16`
#### Returns
`BinaryFp16`
#### Overrides
`BinaryFpBase.sub`
***
### toExponential()
> **toExponential**(`fractionDigits?`): `string`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:135
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-fp16.ts:131
Fixed-point notation with exactly `fractionDigits` places, padded withzeros where the value has fewer — `Number.prototype.toFixed`, without itscap 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-fp16.ts:139
`precision` significant digits, switching to exponential notation at thesame 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-fp16.ts:127
The shortest numeral that round-trips, or `radix` when given.
#### 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-fp16.ts:155
Returns the underlying `number` value (float16-rounded).
#### Returns
`number`
#### Implementation of
[`INum`](../interfaces/INum.md).[`valueOf`](../interfaces/INum.md#valueof)
#### Overrides
`BinaryFpBase.valueOf`
***
### zero()
> **zero**(): `BinaryFp16`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:218
Returns the additive identity `0.0h`.
#### Returns
`BinaryFp16`
#### Overrides
`BinaryFpBase.zero`
***
### from()
> `static` **from**(`value`): `BinaryFp16`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:90
Creates a `BinaryFp16` from a `number` or parseable numeric string.
#### Parameters
##### value
`string` \| `number`
#### Returns
`BinaryFp16`
***
### fromBits()
> `static` **fromBits**(`bits`): `BinaryFp16`
Defined in: packages/math-numbers/src/num/binary-fp16.ts:99
Creates a `BinaryFp16` from a raw 16-bit IEEE 754 bit pattern.
#### Parameters
##### bits
`number`
16-bit unsigned integer bit pattern (values 0–65535).
#### Returns
`BinaryFp16`