diff options
author | Kaveh R. Ghazi <ghazi@caip.rutgers.edu> | 2006-09-16 02:54:29 +0000 |
---|---|---|
committer | Kaveh Ghazi <ghazi@gcc.gnu.org> | 2006-09-16 02:54:29 +0000 |
commit | e757d6b2316db67d65a36f9e85c9b0429034684b (patch) | |
tree | e3b8e61644cb0efde5db5519495eead32d2565c4 /libdecnumber | |
parent | a22719c10021f57c3989a58982ec4b4ee103a687 (diff) | |
download | gcc-e757d6b2316db67d65a36f9e85c9b0429034684b.zip gcc-e757d6b2316db67d65a36f9e85c9b0429034684b.tar.gz gcc-e757d6b2316db67d65a36f9e85c9b0429034684b.tar.bz2 |
decNumber.c (decNumberPower): Constify.
* decNumber.c (decNumberPower): Constify.
* decNumber.h (decNumberPower): Likewise.
From-SVN: r116990
Diffstat (limited to 'libdecnumber')
-rw-r--r-- | libdecnumber/ChangeLog | 5 | ||||
-rw-r--r-- | libdecnumber/decNumber.c | 14 | ||||
-rw-r--r-- | libdecnumber/decNumber.h | 4 |
3 files changed, 15 insertions, 8 deletions
diff --git a/libdecnumber/ChangeLog b/libdecnumber/ChangeLog index 3661c7c..c5dea7f 100644 --- a/libdecnumber/ChangeLog +++ b/libdecnumber/ChangeLog @@ -1,3 +1,8 @@ +2006-09-15 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * decNumber.c (decNumberPower): Constify. + * decNumber.h (decNumberPower): Likewise. + 2006-09-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> * configure.ac (ACX_PROG_CC_WARNING_OPTS): Add -Wcast-qual. diff --git a/libdecnumber/decNumber.c b/libdecnumber/decNumber.c index a086327..039d19a 100644 --- a/libdecnumber/decNumber.c +++ b/libdecnumber/decNumber.c @@ -964,13 +964,13 @@ decNumberNormalize (decNumber * res, const decNumber * rhs, decContext * set) /* Specification restriction: abs(n) must be <=999999999 */ /* ------------------------------------------------------------------ */ decNumber * -decNumberPower (decNumber * res, decNumber * lhs, - decNumber * rhs, decContext * set) +decNumberPower (decNumber * res, const decNumber * lhs, + const decNumber * rhs, decContext * set) { decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */ decNumber *allocrhs = NULL; /* .., rhs */ decNumber *allocdac = NULL; /* -> allocated acc buffer, iff used */ - decNumber *inrhs = rhs; /* save original rhs */ + const decNumber *inrhs = rhs; /* save original rhs */ Int reqdigits = set->digits; /* requested DIGITS */ Int n; /* RHS in binary */ Int i; /* work */ @@ -1117,6 +1117,7 @@ decNumberPower (decNumber * res, decNumber * lhs, /* we'll invert the lhs now rather than inverting the result later */ if (decNumberIsNegative (rhs)) { /* was a **-n [hence digits>0] */ + decNumber * newlhs; decNumberCopy (&dnOne, dac); /* dnOne=1; [needed now or later] */ #if DECSUBSET if (set->extended) @@ -1138,13 +1139,14 @@ decNumberPower (decNumber * res, decNumber * lhs, status |= DEC_Insufficient_storage; break; } - lhs = alloclhs; /* use the allocated space */ + newlhs = alloclhs; /* use the allocated space */ } else - lhs = (decNumber *) lhsbuff; /* use stack storage */ + newlhs = (decNumber *) lhsbuff; /* use stack storage */ /* [lhs now points to buffer or allocated storage] */ - decNumberCopy (lhs, dac); /* copy the 1/lhs */ + decNumberCopy (newlhs, dac); /* copy the 1/lhs */ decNumberCopy (dac, &dnOne); /* restore acc=1 */ + lhs = newlhs; #if DECSUBSET } #endif diff --git a/libdecnumber/decNumber.h b/libdecnumber/decNumber.h index a64a4d5..2357fbe 100644 --- a/libdecnumber/decNumber.h +++ b/libdecnumber/decNumber.h @@ -152,8 +152,8 @@ decNumber *decNumberMultiply (decNumber *, const decNumber *, const decNumber *, decContext *); decNumber *decNumberNormalize (decNumber *, const decNumber *, decContext *); decNumber *decNumberPlus (decNumber *, const decNumber *, decContext *); -decNumber *decNumberPower (decNumber *, decNumber *, decNumber *, - decContext *); +decNumber *decNumberPower (decNumber *, const decNumber *, + const decNumber *, decContext *); decNumber *decNumberQuantize (decNumber *, const decNumber *, const decNumber *, decContext *); decNumber *decNumberRemainder (decNumber *, const decNumber *, |