diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2023-09-17 17:06:50 +0200 |
---|---|---|
committer | Niklas Haas <github-daiK1o@haasn.dev> | 2023-10-14 12:30:46 +0200 |
commit | 9dddfc4fcce5f1ce0978d6bc3a964fdc6da48e05 (patch) | |
tree | e5099d96c95a131ca072524a0b44c04b320f7a1f /options/m_option.c | |
parent | 52fc3784942d572a790acf59144977160ac685ed (diff) | |
download | mpv-9dddfc4fcce5f1ce0978d6bc3a964fdc6da48e05.tar.bz2 mpv-9dddfc4fcce5f1ce0978d6bc3a964fdc6da48e05.tar.xz |
player/command: change how floating point number are printed
Use "%.7g" to show 7 significant digits. Removes the trailing zeros, and
in general makes it more readable, than fixed 3 decimal digits.
For avsync use "%+.2g" to add plus sign, similar to display-sync
values.
Diffstat (limited to 'options/m_option.c')
-rw-r--r-- | options/m_option.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/options/m_option.c b/options/m_option.c index 892c38b422..7d3222b1d3 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -1023,12 +1023,12 @@ static char *print_double(const m_option_t *opt, const void *val) return talloc_asprintf(NULL, "%f", f); } -static char *print_double_f3(const m_option_t *opt, const void *val) +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, "%.3f", f); + return talloc_asprintf(NULL, "%.7g", f); } static void add_double(const m_option_t *opt, void *val, double add, bool wrap) @@ -1100,7 +1100,7 @@ const m_option_type_t m_option_type_double = { .size = sizeof(double), .parse = parse_double, .print = print_double, - .pretty_print = print_double_f3, + .pretty_print = print_double_7g, .copy = copy_opt, .add = add_double, .multiply = multiply_double, @@ -1126,7 +1126,7 @@ const m_option_type_t m_option_type_aspect = { .flags = M_OPT_TYPE_CHOICE | M_OPT_TYPE_USES_RANGE, .parse = parse_double_aspect, .print = print_double, - .pretty_print = print_double_f3, + .pretty_print = print_double_7g, .copy = copy_opt, .add = add_double, .multiply = multiply_double, @@ -1157,7 +1157,7 @@ static char *print_float(const m_option_t *opt, const void *val) static char *print_float_f3(const m_option_t *opt, const void *val) { double tmp = VAL(val); - return print_double_f3(opt, &tmp); + return print_double_7g(opt, &tmp); } static void add_float(const m_option_t *opt, void *val, double add, bool wrap) |