Embedded SDK
Embedded SDK
Functions
format.c File Reference
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#include "format.h"
Include dependency graph for format.c:

Go to the source code of this file.

Functions

bool format_i64 (char *dst, size_t dst_len, const int64_t value)
 
bool format_u64 (char *out, size_t outLen, uint64_t in)
 
bool format_fpu64 (char *dst, size_t dst_len, const uint64_t value, uint8_t decimals)
 
bool format_fpu64_trimmed (char *dst, size_t dst_len, const uint64_t value, uint8_t decimals)
 
int format_hex (const uint8_t *in, size_t in_len, char *out, size_t out_len)
 

Function Documentation

◆ format_fpu64()

bool format_fpu64 ( char *  dst,
size_t  dst_len,
const uint64_t  value,
uint8_t  decimals 
)

Format 64-bit unsigned integer as string with decimals.

Parameters
[out]dstPointer to output string.
[in]dst_lenLength of output string.
[in]value64-bit unsigned integer to format.
[in]decimalsNumber of digits after decimal separator.
Returns
true if success, false otherwise.

Definition at line 101 of file format.c.

◆ format_fpu64_trimmed()

bool format_fpu64_trimmed ( char *  dst,
size_t  dst_len,
const uint64_t  value,
uint8_t  decimals 
)

Format 64-bit unsigned integer as string with decimals and trimmed zeros and dot.

Parameters
[out]dstPointer to output string.
[in]dst_lenLength of output string.
[in]value64-bit unsigned integer to format.
[in]decimalsNumber of digits after decimal separator.
Returns
true if success, false otherwise.

Definition at line 137 of file format.c.

◆ format_hex()

int format_hex ( const uint8_t in,
size_t  in_len,
char *  out,
size_t  out_len 
)

Format byte buffer to uppercase hexadecimal string.

Parameters
[in]inPointer to input byte buffer.
[in]in_lenLength of input byte buffer.
[out]outPointer to output string.
[in]out_lenLength of output string.
Returns
number of bytes written if success, -1 otherwise.

Definition at line 156 of file format.c.

◆ format_i64()

bool format_i64 ( char *  dst,
size_t  dst_len,
const int64_t  value 
)

Format 64-bit signed integer as string.

Parameters
[out]dstPointer to output string.
[in]dst_lenLength of output string.
[in]value64-bit signed integer to format.
Returns
true if success, false otherwise.

Definition at line 24 of file format.c.

◆ format_u64()

bool format_u64 ( char *  dst,
size_t  dst_len,
uint64_t  value 
)

Format 64-bit unsigned integer as string.

Parameters
[out]dstPointer to output string.
[in]dst_lenLength of output string.
[in]value64-bit unsigned integer to format.
Returns
true if success, false otherwise.

Definition at line 65 of file format.c.