diff options
Diffstat (limited to 'mpi-patches/mpi-to-double')
-rw-r--r-- | mpi-patches/mpi-to-double | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/mpi-patches/mpi-to-double b/mpi-patches/mpi-to-double deleted file mode 100644 index 3facb923..00000000 --- a/mpi-patches/mpi-to-double +++ /dev/null @@ -1,58 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2015-02-07 19:33:11.780282866 -0800 -+++ mpi-1.8.6/mpi.c 2015-02-07 19:33:14.608233363 -0800 -@@ -14,6 +14,7 @@ - #include <stdlib.h> - #include <string.h> - #include <ctype.h> -+#include <math.h> - - typedef unsigned char mem_t; - extern mem_t *chk_calloc(size_t n, size_t size); -@@ -2333,6 +2334,29 @@ - - /* }}} */ - -+mp_err mp_to_double(mp_int *mp, double *d) -+{ -+ int ix; -+ mp_size used = USED(mp); -+ mp_digit *dp = DIGITS(mp); -+ static double mult; -+ double out = dp[used - 1]; -+ -+ if (!mult) -+ mult = pow(2.0, MP_DIGIT_BIT); -+ -+ for (ix = (int) used - 2; ix >= 0; ix--) { -+ out = out * mult; -+ out += (double) dp[ix]; -+ } -+ -+ if (SIGN(mp) == MP_NEG) -+ out = -out; -+ -+ *d = out; -+ return MP_OKAY; -+} -+ - /*------------------------------------------------------------------------*/ - /* {{{ mp_print(mp, ofp) */ - -Index: mpi-1.8.6/mpi.h -=================================================================== ---- mpi-1.8.6.orig/mpi.h 2015-02-07 19:33:08.688337078 -0800 -+++ mpi-1.8.6/mpi.h 2015-02-07 19:33:14.612233293 -0800 -@@ -187,6 +187,11 @@ - #endif /* end MP_NUMTH */ - - /*------------------------------------------------------------------------*/ -+/* Conversions */ -+ -+mp_err mp_to_double(mp_int *mp, double *d); -+ -+/*------------------------------------------------------------------------*/ - /* Input and output */ - - #if MP_IOFUNC |