NAME
u16_fmt, u16_fmtg, u16_0fmt - write an u16 as decimal value into a byte array
u16_xfmt, u16_0xfmt - write an u16 as hexadecimal value into a byte array
u16_ofmt, u16_0ofmt - write an u16 as octal value into a byte array
u16_bfmt, u16_0bfmt - write an u16 as binary value into a byte array
SYNOPSIS
#include <limb/u16.h>
size_t u16_fmt(char *s, u16 u) size_t u16_0fmt(char *s, u16 u, size_t min) size_t u16_fmtg(char *s, u16 u) size_t u16_0fmtg(char *s, u16 u, size_t min) size_t u16_xfmt(char *s, u16 u) size_t u16_0xfmt(char *s, u16 u, size_t min) size_t u16_ofmt(char *s, u16 u) size_t u16_0ofmt(char *s, u16 u, size_t min) size_t u16_bfmt(char *s, u16 u) size_t u16_0bfmt(char *s, u16 u, size_t min)
DESCRIPTION
The u16_fmt
() macro will write into s
the value of u
in decimal.
The u16_0fmt
() macro will write into s
the value of u
in decimal,
prefixing it with leading zeroes if it requires less than min
characters to do
so.
The u16_fmtg
() and u16_0fmtg
() macros are similar, only they will use a
coma (,
) as thousand separator as needed.
The u16_xfmt
() and u16_0xfmt
() macros are similar, only putting the value
of u
in hexadecimal.
The u16_ofmt
() and u16_0ofmt
() macros are similar, only putting the value
of u
in octal.
The u16_bfmt
() and u16_0bfmt
() macros are similar, only putting the value
of u
in binary.
It is possible to use NULL
as s
to only have length computation performed.
Note that those are macros to u64_fmt_generic(3) and u64_0fmt_generic(3).
Constants
Some constants are available if needed, e.g. to allocate a buffer large enough :
U16_FMT
Maximum number of char
needed to hold a decimal string
U16_FMTG
Maximum number of char
needed to hold a thousand-separated decimal string
U16_XFMT
Maximum number of char
needed to hold an hexadecimal string
U16_OFMT
Maximum number of char
needed to hold an octal string
U16_BFMT
Maximum number of char
needed to hold a binary string
Note that all of those include an extra char
for a proper NUL-terminated
string.
RETURN VALUE
All of these return the length of the string written into s
, or required to
do so when s
is NULL