Welcome to little lamb

Code » limb » master » tree

[master] / src / doc / u16.h / u16_pack.3.md

% limb manual
% u16_pack(3)
% limb 0.1.0
% 2023-07-24

# NAME

u16_pack, u16_unpack, u16_pack_big, u16_unpack_big - store/read an u16 into/from
a byte array

# SYNOPSIS

    #include <limb/u16.h>

```pre hl
void u16_pack(void *<em>dst</em>, u16 <em>val</em>)
void u16_unpack(u16 *<em>val</em>, const void *<em>sce</em>)

void u16_pack_big(void *<em>dst</em>, u16 <em>val</em>)
void u16_unpack_big(u16 *<em>val</em>, const void *<em>sce</em>)
```

# DESCRIPTION

All of these aim to either store the given number `val` into the specified
byte array `dst`, or read a number from the specified byte array `sce` and set
the value pointed by `val` to its value.

The `u16_pack`() function stores the number `val` into the 2 bytes pointed by
`dst`, encoded as little endian.

The `u16_unpack`() function reads 2 bytes pointed by `sce` as little endian
encoded number, setting the value pointed by `val` to its value.

The `u16_pack_big`() function is similar to `u16_pack`() only as big endian.

The `u16_unpack_big`() function is similar to `u16_unpack`() only as big endian.