diff options
author | Jaroslav Kysela <perex@perex.cz> | 2013-05-28 08:43:30 +0200 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2013-05-28 08:43:30 +0200 |
commit | c80a38dbf53531d57c9bd4ccdc05553bd7fb79a1 (patch) | |
tree | 0d97e288bb8f43009ea69dac729cbce8a16194b8 | |
parent | d61924fd247c2cf0280391e076c439c9427732aa (diff) | |
download | alsa-utils-c80a38dbf53531d57c9bd4ccdc05553bd7fb79a1.tar.gz |
amixer: fix print_dB for -0.99 .. -0.01 range
The first number is 0 when input dB (hundreds) is in range -99 .. -1 .
The printed number was positive in this case. This patch fixes this issue.
Reported-by: Tom Becker <GTBecker@RighTime.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r-- | amixer/amixer.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/amixer/amixer.c b/amixer/amixer.c index 92b0f83..fe83b49 100644 --- a/amixer/amixer.c +++ b/amixer/amixer.c @@ -431,7 +431,11 @@ static void print_spaces(unsigned int spaces) static void print_dB(long dB) { - printf("%li.%02lidB", dB / 100, (dB < 0 ? -dB : dB) % 100); + if (dB < 0) { + printf("-%li.%02lidB", -dB / 100, -dB % 100); + } else { + printf("%li.%02lidB", dB / 100, dB % 100); + } } static void decode_tlv(unsigned int spaces, unsigned int *tlv, unsigned int tlv_size) |