summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/libntp/dofptoa.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ntp/libntp/dofptoa.c')
-rw-r--r--contrib/ntp/libntp/dofptoa.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/contrib/ntp/libntp/dofptoa.c b/contrib/ntp/libntp/dofptoa.c
index 0f96909..758af2f 100644
--- a/contrib/ntp/libntp/dofptoa.c
+++ b/contrib/ntp/libntp/dofptoa.c
@@ -1,6 +1,7 @@
/*
* dofptoa - do the grunge work to convert an fp number to ascii
*/
+#include <config.h>
#include <stdio.h>
#include "ntp_fp.h"
@@ -32,7 +33,7 @@ dofptoa(
/*
* Zero out the buffer
*/
- memset((char *)cbuf, 0, sizeof cbuf);
+ ZERO(cbuf);
/*
* Set the pointers to point at the first
@@ -116,3 +117,43 @@ dofptoa(
*bp = '\0';
return buf;
}
+
+
+char *
+fptoa(
+ s_fp fpv,
+ short ndec
+ )
+{
+ u_fp plusfp;
+ int neg;
+
+ neg = (fpv < 0);
+ if (neg) {
+ plusfp = (u_fp)(-fpv);
+ } else {
+ plusfp = (u_fp)fpv;
+ }
+
+ return dofptoa(plusfp, neg, ndec, FALSE);
+}
+
+
+char *
+fptoms(
+ s_fp fpv,
+ short ndec
+ )
+{
+ u_fp plusfp;
+ int neg;
+
+ neg = (fpv < 0);
+ if (neg) {
+ plusfp = (u_fp)(-fpv);
+ } else {
+ plusfp = (u_fp)fpv;
+ }
+
+ return dofptoa(plusfp, neg, ndec, TRUE);
+}
OpenPOWER on IntegriCloud