---
name: "mtbl_fixed"
section: "3"
platform: "linux"
package: "libmtbl-dev"
version: "1.6.1-1+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mtbl_fixed"
---

# mtbl\_fixed(3)

Fixed-width encoding and decoding of 32 and 64 bit integers

## NAME

mtbl\_fixed - Fixed-width encoding and decoding of 32 and 64 bit integers

## SYNOPSIS

**#include \<mtbl.h\>**

**size\_t mtbl\_fixed\_encode32(uint8\_t \****dst***, uint32\_t** *value***);**

**size\_t mtbl\_fixed\_encode64(uint8\_t \****dst***, uint64\_t** *value***);**

**uint32\_t mtbl\_fixed\_decode32(const uint8\_t \****ptr***);**

**uint64\_t mtbl\_fixed\_decode64(const uint8\_t \****ptr***);**

## DESCRIPTION

**mtbl\_fixed\_encode32**() and **mtbl\_fixed\_encode64**() write the 32 or 64 bit quantity, respectively, in the argument *value* to the buffer in the argument *dst*. The quantity will be written in little endian order, regardless of host architecture.

**mtbl\_fixed\_decode32**() and **mtbl\_fixed\_decode64**() read and return the 32 or 64 bit quantity, respectively, in the argument *ptr*. The quantity will be read in little endian order, regardless of host architecture.

Bounds checking must be performed by the caller.

## RETURN VALUE

**mtbl\_fixed\_encode32**() and **mtbl\_fixed\_encode64**() return the number of bytes written to the buffer. (4 or 8, respectively.)

**mtbl\_fixed\_decode32**() and **mtbl\_fixed\_decode64**() return the decoded quantity.
