From: Ramakrishnan Muthukrishnan Date: Wed, 12 Jan 2022 07:18:07 +0000 (+0530) Subject: use the C round function X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/(%5B%5E?a=commitdiff_plain;h=4e8fdcba84e1a37b158044d881772cb6608b9bec;p=pihpsdr.git use the C round function --- 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;