php-dextrin

FloatWidth
in package

FinalYes

CBOR's half- and single-precision floats (RFC 8949 §3.3, Appendix D), which `.dxnb` writes when they hold a value exactly -- the smallest representation (DXN.md §2.2, Jan, 2026-10-20). Named for what it chooses, as `Float` is a name PHP keeps for itself.

Everything here works on the double's bits rather than on logarithms, so "exactly" means exactly: a float fits a width when no bit of it is lost there, the sign of a zero included.

Table of Contents

Constants

MANTISSA  : mixed = 0xfffffffffffff
A double's 52 mantissa bits.

Methods

fromHalf()  : float
A half-precision float's 16 bits as the float they hold.
half()  : int|null
`$f`'s half-precision bits, when half precision holds it exactly; NaN is the quiet NaN `0x7E00`, the infinities `0x7C00` and `0xFC00`.
single()  : bool
Whether single precision holds `$f` exactly.
__construct()  : mixed
doubleBits()  : int
`$f`'s IEEE 754 double bits, the sign bit PHP's int sign.

Constants

MANTISSA

A double's 52 mantissa bits.

private mixed MANTISSA = 0xfffffffffffff

Methods

fromHalf()

A half-precision float's 16 bits as the float they hold.

public static fromHalf(int $bits) : float
Parameters
$bits : int
Return values
float

half()

`$f`'s half-precision bits, when half precision holds it exactly; NaN is the quiet NaN `0x7E00`, the infinities `0x7C00` and `0xFC00`.

public static half(float $f) : int|null
Parameters
$f : float
Return values
int|null

single()

Whether single precision holds `$f` exactly.

public static single(float $f) : bool
Parameters
$f : float
Return values
bool

doubleBits()

`$f`'s IEEE 754 double bits, the sign bit PHP's int sign.

private static doubleBits(float $f) : int
Parameters
$f : float
Return values
int
On this page

Search results