aboutsummaryrefslogtreecommitdiff
path: root/src/benchmarks/cfrac/ltop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/benchmarks/cfrac/ltop.c')
-rw-r--r--src/benchmarks/cfrac/ltop.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/benchmarks/cfrac/ltop.c b/src/benchmarks/cfrac/ltop.c
new file mode 100644
index 0000000..33eaea5
--- /dev/null
+++ b/src/benchmarks/cfrac/ltop.c
@@ -0,0 +1,25 @@
+#include "pdefs.h"
+#include "pcvt.h"
+#include "precision.h"
+
+/*
+ * Long to Precision
+ */
+precision ltop(l)
+ register long l;
+{
+ register digitPtr uPtr;
+ register precision u = palloc(LONGSIZE);
+
+ if (u == pUndef) return u;
+
+ if (u->sign = (l < 0L)) l = -l;
+ uPtr = u->value;
+ do {
+ *uPtr++ = modBase(l);
+ l = divBase(l);
+ } while (l != 0);
+
+ u->size = (uPtr - u->value); /* normalize */
+ return presult(u);
+}