player/command: truncate anything < 1e-4 in pretty printer

To avoid switching to scientific notation. Apparently it is "jarring"
for some users.

This preserves status quo from before 9dddfc4f where pretty printer were
truncated to 3 decimal places.
This commit is contained in:
Kacper Michajłow
2023-10-17 02:53:11 +02:00
committed by sfan5
parent 11bbb49bdf
commit 02d009bc5c
2 changed files with 8 additions and 3 deletions

View File

@@ -1028,7 +1028,12 @@ static char *print_double_7g(const m_option_t *opt, const void *val)
double f = VAL(val);
if (isnan(f))
return print_double(opt, val);
return talloc_asprintf(NULL, "%.7g", f);
// Truncate anything < 1e-4 to avoid switching to scientific notation
if (fabs(f) < 1e-4) {
return talloc_strdup(NULL, "0");
} else {
return talloc_asprintf(NULL, "%.7g", f);
}
}
static void add_double(const m_option_t *opt, void *val, double add, bool wrap)