From beb33fca697e4a7ecfe1661d0699a0d55f23f03a Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Fri, 25 May 2012 11:47:06 -0700 Subject: [PATCH] avprobe: improve formatting Do not use decimals if not needed. --- avprobe.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/avprobe.c b/avprobe.c index 6182875d91..5df6937db5 100644 --- a/avprobe.c +++ b/avprobe.c @@ -90,11 +90,12 @@ static char *value_string(char *buf, int buf_size, double val, const char *unit) val /= pow(10, index * 3); prefix_string = decimal_unit_prefixes[index]; } - - snprintf(buf, buf_size, "%.3f %s%s", val, prefix_string, + snprintf(buf, buf_size, "%.*f%s%s", + index ? 3 : 0, val, + prefix_string, show_value_unit ? unit : ""); } else { - snprintf(buf, buf_size, "%f %s", val, show_value_unit ? unit : ""); + snprintf(buf, buf_size, "%f%s", val, show_value_unit ? unit : ""); } return buf;