Welcome to little lamb

Code » limb » master » tree

[master] / src / doc / u64.h / u64_fmt_generic.3.md

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

# NAME

u64_fmt_generic, u64_0fmt_generic - write an u64 number into a byte array

# SYNOPSIS

    #include <limb/u64.h>

```pre hl
size_t u64_fmt_generic(char *<em>s</em>, u64 <em>u</em>, u8 <em>base</em>, u8 <em>grp</em>, const char <em>sep</em>)
size_t u64_0fmt_generic(char *<em>s</em>, u64 <em>u</em>, u8 <em>base</em>, size_t <em>min</em>, const char <em>fill</em>,
                        u8 <em>grp</em>, const char <em>sep</em>)
```

# DESCRIPTION

The `u64_fmt_generic`() function will put into `s` the value of `u` encoded in
base `base`. If `grp` is not zero, `sep` will be used as separator every `grp`
characters, starting from the end.

The `u64_0fmt_generic`() function is similar, only if the size needed is less
than `min` it will fill it up by prefixing it using as many instances of `fill`
as needed.

It is possible to use `NULL` as `s` to only have length computation performed.

## Macros

Note that many macros are available for ease of use, such as [u64_fmt](3),
[u32_fmt](3) or [u16_fmt](3) and their related macros.

# RETURN VALUE

Both functions return the length of the string written into `s`, or required to
do so when `s` is `NULL`