summaryrefslogtreecommitdiff
path: root/mpq/set_d.c
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2012-02-24 11:14:11 +0100
committerMarc Glisse <marc.glisse@inria.fr>2012-02-24 11:14:11 +0100
commit15cafc39ad37fb3f06cd0e769f855b199288fdf4 (patch)
treee81213fb0aa75cb6d8e069d3fd6caaf0be7c985d /mpq/set_d.c
parent38a9408ef532be12fb53f765541d32f014302f99 (diff)
downloadgmp-15cafc39ad37fb3f06cd0e769f855b199288fdf4.tar.gz
Use macros like NUM, ALLOC, SIZ, etc in mpq/*.
Test some mpq functions that were not used in the testsuite. Implement q=z (in gmpxx) with mpq_set_z.
Diffstat (limited to 'mpq/set_d.c')
-rw-r--r--mpq/set_d.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/mpq/set_d.c b/mpq/set_d.c
index 1e806f80a..7367826cc 100644
--- a/mpq/set_d.c
+++ b/mpq/set_d.c
@@ -64,15 +64,15 @@ mpq_set_d (mpq_ptr dest, double d)
{
if (d == 0.0)
{
- SIZ(&(dest->_mp_num)) = 0;
- SIZ(&(dest->_mp_den)) = 1;
- PTR(&(dest->_mp_den))[0] = 1;
+ SIZ(NUM(dest)) = 0;
+ SIZ(DEN(dest)) = 1;
+ PTR(DEN(dest))[0] = 1;
return;
}
dn = -exp;
- MPZ_REALLOC (&(dest->_mp_num), 3);
- np = PTR(&(dest->_mp_num));
+ MPZ_REALLOC (NUM(dest), 3);
+ np = PTR(NUM(dest));
#if LIMBS_PER_DOUBLE == 4
if ((tp[0] | tp[1] | tp[2]) == 0)
np[0] = tp[3], nn = 1;
@@ -99,8 +99,8 @@ mpq_set_d (mpq_ptr dest, double d)
#endif
dn += nn + 1;
ASSERT_ALWAYS (dn > 0);
- MPZ_REALLOC (&(dest->_mp_den), dn);
- dp = PTR(&(dest->_mp_den));
+ MPZ_REALLOC (DEN(dest), dn);
+ dp = PTR(DEN(dest));
MPN_ZERO (dp, dn - 1);
dp[dn - 1] = 1;
count_trailing_zeros (c, np[0] | dp[0]);
@@ -111,14 +111,14 @@ mpq_set_d (mpq_ptr dest, double d)
mpn_rshift (dp, dp, dn, c);
dn -= dp[dn - 1] == 0;
}
- SIZ(&(dest->_mp_den)) = dn;
- SIZ(&(dest->_mp_num)) = negative ? -nn : nn;
+ SIZ(DEN(dest)) = dn;
+ SIZ(NUM(dest)) = negative ? -nn : nn;
}
else
{
nn = exp;
- MPZ_REALLOC (&(dest->_mp_num), nn);
- np = PTR(&(dest->_mp_num));
+ MPZ_REALLOC (NUM(dest), nn);
+ np = PTR(NUM(dest));
switch (nn)
{
default:
@@ -150,9 +150,9 @@ mpq_set_d (mpq_ptr dest, double d)
break;
#endif
}
- dp = PTR(&(dest->_mp_den));
+ dp = PTR(DEN(dest));
dp[0] = 1;
- SIZ(&(dest->_mp_den)) = 1;
- SIZ(&(dest->_mp_num)) = negative ? -nn : nn;
+ SIZ(DEN(dest)) = 1;
+ SIZ(NUM(dest)) = negative ? -nn : nn;
}
}