Functions
getI64Codec
getI64Codec(
config
):FixedSizeCodec
<number
|bigint
,bigint
,8
>
Returns a codec for encoding and decoding 64-bit signed integers (i64
).
This codec serializes i64
values using 8 bytes.
Values can be provided as either number
or bigint
, but the decoded value is always a bigint
.
Parameters
Parameter | Type | Description |
---|---|---|
config | NumberCodecConfig | Optional configuration to specify endianness (little by default). |
Returns
FixedSizeCodec
<number
| bigint
, bigint
, 8
>
A FixedSizeCodec<number | bigint, bigint, 8>
for encoding and decoding i64
values.
Examples
Encoding and decoding an i64
value.
Using big-endian encoding.
Remarks
This codec supports values between -2^63
and 2^63 - 1
.
Since JavaScript number
cannot safely represent values beyond 2^53 - 1
, the decoded value is always a bigint
.
- If you need a smaller signed integer, consider using getI32Codec or getI16Codec.
- If you need a larger signed integer, consider using getI128Codec.
- If you need unsigned integers, consider using getU64Codec.
Separate getI64Encoder and getI64Decoder functions are available.