diff options
author | tege <tege@gmplib.org> | 2006-02-28 03:00:49 +0100 |
---|---|---|
committer | tege <tege@gmplib.org> | 2006-02-28 03:00:49 +0100 |
commit | 4a821103e6705c77f8e3f7f1222c5524a2a4b7e2 (patch) | |
tree | f8a777bf12171b9f2df9ef69d1e77bb9d66ee3fa /extract-dbl.c | |
parent | 06fcbfbeb5dcc862e78eb3a9e1f172af44bc0ea1 (diff) | |
download | gmp-4a821103e6705c77f8e3f7f1222c5524a2a4b7e2.tar.gz |
Make it work for LIMBS_PER_DOUBLE > 3.
Diffstat (limited to 'extract-dbl.c')
-rw-r--r-- | extract-dbl.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/extract-dbl.c b/extract-dbl.c index 5653fa344..356a9c577 100644 --- a/extract-dbl.c +++ b/extract-dbl.c @@ -245,25 +245,33 @@ __gmp_extract_double (mp_ptr rp, double d) #endif #if LIMBS_PER_DOUBLE > 3 - /* Insert code for splitting manh,,manl into LIMBS_PER_DOUBLE - mp_limb_t's at rp. */ - if (sc != 0) + if (sc == 0) { - /* This is not perfect, and would fail for GMP_LIMB_BITS == 16. - The ASSERT_ALWAYS should catch the problematic cases. */ - ASSERT_ALWAYS ((manl << sc) == 0); - manl = (manh << sc) | (manl >> (GMP_LIMB_BITS - sc)); - manh = manh >> (GMP_LIMB_BITS - sc); + int i; + + for (i = LIMBS_PER_DOUBLE - 1; i >= 0; i--) + { + rp[i] = manh >> (BITS_PER_ULONG - GMP_NUMB_BITS); + manh = ((manh << GMP_NUMB_BITS) + | (manl >> (BITS_PER_ULONG - GMP_NUMB_BITS))); + manl = manl << GMP_NUMB_BITS; + } + exp--; } - { - int i; - for (i = LIMBS_PER_DOUBLE - 1; i >= 0; i--) - { - rp[i] = manh >> (BITS_PER_LONGINT - GMP_LIMB_BITS); - manh = ((manh << GMP_LIMB_BITS) - | (manl >> (BITS_PER_LONGINT - GMP_LIMB_BITS))); - manl = manl << GMP_LIMB_BITS; - } + else + { + int i; + + rp[LIMBS_PER_DOUBLE - 1] = (manh >> (GMP_LIMB_BITS - sc)); + manh = (manh << sc) | (manl >> (GMP_LIMB_BITS - sc)); + manl = (manl << sc); + for (i = LIMBS_PER_DOUBLE - 2; i >= 0; i--) + { + rp[i] = manh >> (BITS_PER_ULONG - GMP_NUMB_BITS); + manh = ((manh << GMP_NUMB_BITS) + | (manl >> (BITS_PER_ULONG - GMP_NUMB_BITS))); + manl = manl << GMP_NUMB_BITS; + } } #endif |