getF32Codec
Returns a codec for encoding and decoding 32-bit floating-point numbers (f32).
This codec serializes f32 values using 4 bytes.
Due to the IEEE 754 floating-point representation, some precision loss may occur.
Parameters
| Parameter | Type | Description |
|---|---|---|
config | NumberCodecConfig | Optional configuration to specify endianness (little by default). |
Returns
FixedSizeCodec<number | bigint, number, 4>
A FixedSizeCodec<number, number, 4> for encoding and decoding f32 values.
Examples
Encoding and decoding an f32 value.
Using big-endian encoding.
Remarks
f32 values follow the IEEE 754 single-precision floating-point standard.
Precision loss may occur for certain values.
- If you need higher precision, consider using getF64Codec.
- If you need integer values, consider using getI32Codec or getU32Codec.
Separate getF32Encoder and getF32Decoder functions are available.