parse-util: add format string macro for outputting permyriad

Let's define a set of macros for making output of permyriad values easy.
They are printed in pure ASCII, i.e. without the permille/permyriad
suffix, using just percent and two places after the dot.
This commit is contained in:
Lennart Poettering
2021-02-18 22:36:34 +01:00
parent 9cba32bcde
commit 1ead0b2a79
3 changed files with 6 additions and 2 deletions
+3
View File
@@ -59,3 +59,6 @@ static inline int UINT32_SCALE_TO_PERMYRIAD(uint32_t scale) {
return (int) u;
}
#define PERMYRIAD_AS_PERCENT_FORMAT_STR "%i.%02i%%"
#define PERMYRIAD_AS_PERCENT_FORMAT_VAL(x) ((x)/100), ((x)%100)