Skip to content

BinaryFp32

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

IEEE 754 binary32 (single-precision) floating-point number.

Backed by a JS number; each operation rounds the result to single precision via Math.fround before storing it. This faithfully models the behaviour of a hardware float32, including overflow to ±∞ and underflow to ±0.

References:

  • BinaryFpBase<BinaryFp32>

new BinaryFp32(value): BinaryFp32

Defined in: packages/math-numbers/src/num/binary-fp32.ts:80

string | number

BinaryFp32

BinaryFpBase<BinaryFp32>.constructor

readonly static IEEE754: IeeeFormat = IEEE_FORMAT_BINARY32

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

IEEE 754-2008 structural parameters for binary32. b=2, k=32, p=24, emax=127.


readonly static INFINITY: BinaryFp32

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

IEEE 754 positive infinity.


readonly static MAX_VALUE: BinaryFp32

Defined in: packages/math-numbers/src/num/binary-fp32.ts:71

Max finite positive float32 (~3.4028235e38).


readonly static MIN_VALUE: BinaryFp32

Defined in: packages/math-numbers/src/num/binary-fp32.ts:73

Min positive normalised float32 (~1.175494e-38).


readonly static NAN: BinaryFp32

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

IEEE 754 Not-a-Number.


readonly static NEG_INFINITY: BinaryFp32

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

IEEE 754 negative infinity.


readonly static ONE: BinaryFp32

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

Multiplicative identity 1.0f.


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-fp32.ts:47

Unique type tag used by the converter registry.


readonly static TEN: BinaryFp32

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

The value 10.0f.


readonly static TWO: BinaryFp32

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

The value 2.0f.


readonly static ZERO: BinaryFp32

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

Additive identity 0.0f.

get bitWidth(): 32

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

Total width of the representation, in bits.

32

Total width of the representation, in bits.

IFixedPrecision.bitWidth

BinaryFpBase.bitWidth


get decimalPrecision(): number

Defined in: packages/math-numbers/src/num/binary-fp32.ts:170

Number of significant decimal digits (~7 for float32).

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)\<`BinaryFp32`\>
Defined in: packages/math-numbers/src/num/binary-fp32.ts:294
Fixed-precision format descriptor for IEEE 754 binary32.
##### Returns
[`FixedPrecisionInfo`](../type-aliases/FixedPrecisionInfo.md)\<`BinaryFp32`\>
#### Overrides
`BinaryFpBase.formatInfo`
***
### fractionalPrecision
#### Get Signature
> **get** **fractionalPrecision**(): `number`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:184
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-fp32.ts:175
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-fp32.ts:111
`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-fp32.ts:116
`true` if this value is +∞ or −∞.
##### Returns
`boolean`
***
### isNaN
#### Get Signature
> **get** **isNaN**(): `boolean`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:106
`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-fp32.ts:158
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**(): `BinaryFp32`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:266
Absolute value `|x|`.
#### Returns
`BinaryFp32`
#### Overrides
`BinaryFpBase.abs`
***
### add()
> **add**(`other`): `BinaryFp32`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:211
Returns `this + other`, rounded to float32.
#### Parameters
##### other
`BinaryFp32`
#### Returns
`BinaryFp32`
#### Overrides
`BinaryFpBase.add`
***
### bitAt()
> **bitAt**(`position`): `0` \| `1`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:314
Returns the bit at `position` in the IEEE 754 binary32 layout. Position `0`
is the least-significant bit; position `31` is the sign bit.
#### Parameters
##### position
`number`
#### Returns
`0` \| `1`
#### Throws
When `position` is outside `[0, 31]`.
#### Overrides
`BinaryFpBase.bitAt`
***
### clamp()
> **clamp**(`lower`, `upper`): `BinaryFp32`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:69
Restricts the value to `[lower, upper]`.
#### Parameters
##### lower
`BinaryFp32`
##### upper
`BinaryFp32`
#### Returns
`BinaryFp32`
#### Inherited from
`BinaryFpBase.clamp`
***
### cmp()
> **cmp**(`other`): `Sign`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:253
Three-way comparison.
#### Parameters
##### other
`BinaryFp32`
#### Returns
`Sign`
#### Throws
When either value is NaN.
#### Overrides
`BinaryFpBase.cmp`
***
### div()
> **div**(`other`): `BinaryFp32`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:240
Returns `this / other`, rounded to float32.
#### Parameters
##### other
`BinaryFp32`
#### Returns
`BinaryFp32`
#### Overrides
`BinaryFpBase.div`
***
### eq()
> **eq**(`other`): `boolean`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:45
#### Parameters
##### other
`BinaryFp32`
#### Returns
`boolean`
#### Inherited from
`BinaryFpBase.eq`
***
### format()
> **format**(`locales?`, `options?`): `string`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:141
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
`BinaryFp32`
#### Returns
`boolean`
#### Inherited from
`BinaryFpBase.gt`
***
### gte()
> **gte**(`other`): `boolean`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:73
#### Parameters
##### other
`BinaryFp32`
#### Returns
`boolean`
#### Inherited from
`BinaryFpBase.gte`
***
### identity()
> **identity**(): `BinaryFp32`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:202
Returns the multiplicative identity `1.0f`.
#### Returns
`BinaryFp32`
#### Overrides
`BinaryFpBase.identity`
***
### inv()
> **inv**(): `BinaryFp32`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:235
Returns `1 / this`, rounded to float32.
#### Returns
`BinaryFp32`
#### Overrides
`BinaryFpBase.inv`
***
### lt()
> **lt**(`other`): `boolean`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:49
#### Parameters
##### other
`BinaryFp32`
#### Returns
`boolean`
#### Inherited from
`BinaryFpBase.lt`
***
### lte()
> **lte**(`other`): `boolean`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:53
#### Parameters
##### other
`BinaryFp32`
#### Returns
`boolean`
#### Inherited from
`BinaryFpBase.lte`
***
### max()
> **max**(`other`): `BinaryFp32`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:65
The larger of the two operands under the total order.
#### Parameters
##### other
`BinaryFp32`
#### Returns
`BinaryFp32`
#### Inherited from
`BinaryFpBase.max`
***
### min()
> **min**(`other`): `BinaryFp32`
Defined in: packages/math-algebra/src/\_ordered-defaults.ts:61
The smaller of the two operands under the total order.
#### Parameters
##### other
`BinaryFp32`
#### Returns
`BinaryFp32`
#### Inherited from
`BinaryFpBase.min`
***
### mul()
> **mul**(`other`): `BinaryFp32`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:197
Returns `this × other`, rounded to float32.
#### Parameters
##### other
`BinaryFp32`
#### Returns
`BinaryFp32`
#### Overrides
`BinaryFpBase.mul`
***
### neg()
> **neg**(): `BinaryFp32`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:221
Returns `−this`.
#### Returns
`BinaryFp32`
#### Overrides
`BinaryFpBase.neg`
***
### sign()
> **sign**(): `Sign`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:275
Sign of this value.
#### Returns
`Sign`
`-1` for negative, `0` for zero/NaN, `+1` for positive.
#### Overrides
`BinaryFpBase.sign`
***
### sqrt()
> **sqrt**(): `BinaryFp32`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:285
Principal square root `√x`, rounded to float32. Returns `NaN` for negative
inputs.
#### Returns
`BinaryFp32`
#### Overrides
`BinaryFpBase.sqrt`
***
### sub()
> **sub**(`other`): `BinaryFp32`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:226
Returns `this − other`, rounded to float32.
#### Parameters
##### other
`BinaryFp32`
#### Returns
`BinaryFp32`
#### Overrides
`BinaryFpBase.sub`
***
### toExponential()
> **toExponential**(`fractionDigits?`): `string`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:133
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-fp32.ts:129
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-fp32.ts:137
`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-fp32.ts:125
Formats this value as a string using float32 precision (~7 decimal digits).
#### 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-fp32.ts:153
Returns the underlying `number` value (float32-rounded).
#### Returns
`number`
#### Implementation of
[`INum`](../interfaces/INum.md).[`valueOf`](../interfaces/INum.md#valueof)
#### Overrides
`BinaryFpBase.valueOf`
***
### zero()
> **zero**(): `BinaryFp32`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:216
Returns the additive identity `0.0f`.
#### Returns
`BinaryFp32`
#### Overrides
`BinaryFpBase.zero`
***
### from()
> `static` **from**(`value`): `BinaryFp32`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:88
Creates a `BinaryFp32` from a `number` or parseable numeric string.
#### Parameters
##### value
`string` \| `number`
#### Returns
`BinaryFp32`
***
### fromBits()
> `static` **fromBits**(`bits`): `BinaryFp32`
Defined in: packages/math-numbers/src/num/binary-fp32.ts:97
Creates a `BinaryFp32` from raw 32-bit IEEE 754 bit pattern.
#### Parameters
##### bits
`number`
32-bit unsigned integer bit pattern.
#### Returns
`BinaryFp32`