From 3d5ec15729c023a801f44e13d6f10310ca069f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Fillod=2C=20F8CFE?= Date: Fri, 4 May 2001 22:41:22 +0000 Subject: [PATCH] * freq_sprintf to handle negative freqs git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@477 7ae35d74-ebe9-4afe-98af-79ac388436b8 --- src/misc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/misc.c b/src/misc.c index a01e33b67..4f0168141 100644 --- a/src/misc.c +++ b/src/misc.c @@ -6,7 +6,7 @@ * Provides useful routines for data handling, used by backend * as well as by the frontend. * - * $Id: misc.c,v 1.5 2001-04-24 19:52:28 f4cfe Exp $ + * $Id: misc.c,v 1.6 2001-05-04 22:41:22 f4cfe Exp $ * * * This program is free software; you can redistribute it and/or @@ -222,6 +222,7 @@ void rig_debug(enum rig_debug_level_e debug_level, const char *fmt, ...) } } +#define llabs(a) ((a)<0?-(a):(a)) /* * rig_freq_snprintf @@ -233,13 +234,13 @@ int freq_sprintf(char *str, freq_t freq) double f; char *hz; - if (freq >= GHz(1)) { + if (llabs(freq) >= GHz(1)) { hz = "GHz"; f = (double)freq/GHz(1); - } else if (freq >= MHz(1)) { + } else if (llabs(freq) >= MHz(1)) { hz = "MHz"; f = (double)freq/MHz(1); - } else if (freq >= kHz(1)) { + } else if (llabs(freq) >= kHz(1)) { hz = "kHz"; f = (double)freq/kHz(1); } else {