tag: for now, always use 2 decimals for floats

In the future, we’ll want to add a way to specify the number of
decimals, as part of the formatter.
This commit is contained in:
Daniel Eklöf 2022-06-03 19:43:28 +02:00
parent 8a8a40bfb5
commit a8994b9268
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

2
tag.c
View file

@ -583,7 +583,7 @@ tags_expand_template(const char *template, const struct tag_set *tags)
char str[24];
if (tag->type(tag) == TAG_TYPE_FLOAT)
snprintf(str, sizeof(str), "%f", tag->as_float(tag) / (double)divider);
snprintf(str, sizeof(str), "%.2f", tag->as_float(tag) / (double)divider);
else
snprintf(str, sizeof(str), "%lu", tag->as_int(tag) / divider);
sbuf_append(&formatted, str);