Loading...
Searching...
No Matches
number_format.h
Go to the documentation of this file.
1
7#pragma once
8#include <stdbool.h>
9#include <stddef.h>
10#include <stdint.h>
11
16
27void number_group(char *buffer, size_t size, int value);
28
40void fmt_int_or_dash(char *buffer, size_t size, int value, const char *fmt);
41
53void fmt_hundredths(char *buffer, size_t size, int value);
54
66void fmt_pct_signed(char *buffer, size_t size, int value);
67
80void copy_bounded(char *dst, uint8_t cap, const uint8_t *src, uint8_t len);
81
94bool cstring_is_clean(const char *s, uint16_t size);
95
108bool cstring_setting_is_clean(const char *s, uint16_t size, const char *default_str);
109
void fmt_int_or_dash(char *buffer, size_t size, int value, const char *fmt)
Format an integer, or "--" when there is no reading yet.
Definition number_format.c:67
void copy_bounded(char *dst, uint8_t cap, const uint8_t *src, uint8_t len)
Copy bytes into a fixed buffer, taking what fits and terminating it.
Definition number_format.c:98
void number_group(char *buffer, size_t size, int value)
Format an integer with apostrophe thousands separators (e.g. 20358 -> "20'358").
Definition number_format.c:27
bool cstring_setting_is_clean(const char *s, uint16_t size, const char *default_str)
Whether a saved text setting reads as one, where an empty setting can be the real value.
Definition number_format.c:148
bool cstring_is_clean(const char *s, uint16_t size)
Whether a byte range holds a string worth keeping.
Definition number_format.c:119
void fmt_pct_signed(char *buffer, size_t size, int value)
Format hundredths as a signed two-decimal percent, e.g. 125 -> "+1.25%".
Definition number_format.c:89
void fmt_hundredths(char *buffer, size_t size, int value)
Format hundredths as a two-decimal number, e.g. 26174 -> "261.74".
Definition number_format.c:79