From 4e8fdcba84e1a37b158044d881772cb6608b9bec Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Wed, 12 Jan 2022 12:48:07 +0530
Subject: [PATCH] use the C round function

---
 rigctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rigctl.c b/rigctl.c
index 5ab3714..c1f0ce4 100644
--- a/rigctl.c
+++ b/rigctl.c
@@ -1822,12 +1822,12 @@ gboolean parse_extended_cmd(char *command, CLIENT *client) {
         if (command[4] == ';') {
             memset(reply, '\0', 9);
             printf("getting MIC GAIN: %f\n", mic_gain);
-            sprintf(reply, "ZZMG%03d;", (int)(((mic_gain + 12.0 + 0.5) * 100.0 / 62.0)));
+            sprintf(reply, "ZZMG%03d;", (int) round((round(mic_gain + 12.0) * 100.0 / 62.0)));
             send_resp(client->fd, reply);
         } else if (command[7] == ';') {
             command[7] = '\0';
             double gain = (double)strtol(&command[4], NULL, 10);
-            gain = (gain * 62.0 / 100.0) - 12.0 + 0.5;
+            gain = round((gain * 62.0 / 100.0) - 12.0);
             set_mic_gain(gain);
         }
         break;
-- 
2.45.2