summaryrefslogtreecommitdiff
path: root/lib_generic/strmhz.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib_generic/strmhz.c')
-rw-r--r--lib_generic/strmhz.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib_generic/strmhz.c b/lib_generic/strmhz.c
index d0b6bc6..d6da1d1 100644
--- a/lib_generic/strmhz.c
+++ b/lib_generic/strmhz.c
@@ -27,9 +27,11 @@ char *strmhz (char *buf, long hz)
long l, n;
long m;
- n = hz / 1000000L;
+ n = DIV_ROUND(hz, 1000) / 1000L;
l = sprintf (buf, "%ld", n);
- m = (hz % 1000000L) / 1000L;
+
+ hz -= n * 1000000L;
+ m = DIV_ROUND(hz, 1000L);
if (m != 0)
sprintf (buf + l, ".%03ld", m);
return (buf);