#endif
/* Local routines */
-static decNumber *decAddOp (decNumber *, decNumber *, decNumber *,
- decContext *, uByte, uInt *);
+static decNumber *decAddOp (decNumber *, const decNumber *,
+ const decNumber *, decContext *,
+ uByte, uInt *);
static void decApplyRound (decNumber *, decContext *, Int, uInt *);
-static Int decCompare (decNumber * lhs, decNumber * rhs);
-static decNumber *decCompareOp (decNumber *, decNumber *, decNumber *,
+static Int decCompare (const decNumber * lhs, const decNumber * rhs);
+static decNumber *decCompareOp (decNumber *, const decNumber *, const decNumber *,
decContext *, Flag, uInt *);
-static void decCopyFit (decNumber *, decNumber *, decContext *,
+static void decCopyFit (decNumber *, const decNumber *, decContext *,
Int *, uInt *);
-static decNumber *decDivideOp (decNumber *, decNumber *, decNumber *,
+static decNumber *decDivideOp (decNumber *, const decNumber *, const decNumber *,
decContext *, Flag, uInt *);
static void decFinalize (decNumber *, decContext *, Int *, uInt *);
-static Int decGetDigits (Unit *, Int);
+static Int decGetDigits (const Unit *, Int);
#if DECSUBSET
-static Int decGetInt (decNumber *, decContext *);
+static Int decGetInt (const decNumber *, decContext *);
#else
-static Int decGetInt (decNumber *);
+static Int decGetInt (const decNumber *);
#endif
-static decNumber *decMultiplyOp (decNumber *, decNumber *, decNumber *,
- decContext *, uInt *);
-static decNumber *decNaNs (decNumber *, decNumber *, decNumber *, uInt *);
-static decNumber *decQuantizeOp (decNumber *, decNumber *, decNumber *,
- decContext *, Flag, uInt *);
-static void decSetCoeff (decNumber *, decContext *, Unit *,
+static decNumber *decMultiplyOp (decNumber *, const decNumber *,
+ const decNumber *, decContext *, uInt *);
+static decNumber *decNaNs (decNumber *, const decNumber *, const decNumber *, uInt *);
+static decNumber *decQuantizeOp (decNumber *, const decNumber *,
+ const decNumber *, decContext *, Flag, uInt *);
+static void decSetCoeff (decNumber *, decContext *, const Unit *,
Int, Int *, uInt *);
static void decSetOverflow (decNumber *, decContext *, uInt *);
static void decSetSubnormal (decNumber *, decContext *, Int *, uInt *);
static Int decShiftToMost (Unit *, Int, Int);
static void decStatus (decNumber *, uInt, decContext *);
static Flag decStrEq (const char *, const char *);
-static void decToString (decNumber *, char[], Flag);
+static void decToString (const decNumber *, char[], Flag);
static decNumber *decTrim (decNumber *, Flag, Int *);
-static Int decUnitAddSub (Unit *, Int, Unit *, Int, Int, Unit *, Int);
-static Int decUnitCompare (Unit *, Int, Unit *, Int, Int);
+static Int decUnitAddSub (const Unit *, Int, const Unit *, Int, Int, Unit *, Int);
+static Int decUnitCompare (const Unit *, Int, const Unit *, Int, Int);
#if !DECSUBSET
/* decFinish == decFinalize when no subset arithmetic needed */
#define decFinish(a,b,c,d) decFinalize(a,b,c,d)
#else
static void decFinish (decNumber *, decContext *, Int *, uInt *);
-static decNumber *decRoundOperand (decNumber *, decContext *, uInt *);
+static decNumber *decRoundOperand (const decNumber *, decContext *, uInt *);
#endif
/* Diagnostic macros, etc. */
/* fastest routines (and adds 600+ bytes), so should not normally be */
/* used in 'production'. */
#define DECUNUSED (void *)(0xffffffff)
-static Flag decCheckOperands (decNumber *, decNumber *, decNumber *,
- decContext *);
-static Flag decCheckNumber (decNumber *, decContext *);
+static Flag decCheckOperands (decNumber *, const decNumber *,
+ const decNumber *, decContext *);
+static Flag decCheckNumber (const decNumber *, decContext *);
#endif
#if DECTRACE || DECCHECK
/* Optional trace/debugging routines. */
-void decNumberShow (decNumber *); /* displays the components of a number */
-static void decDumpAr (char, Unit *, Int);
+void decNumberShow (const decNumber *); /* displays the components of a number */
+static void decDumpAr (char, const Unit *, Int);
#endif
/* ================================================================== */
/* No error is possible, and no status can be set. */
/* ------------------------------------------------------------------ */
char *
-decNumberToString (decNumber * dn, char *string)
+decNumberToString (const decNumber * dn, char *string)
{
decToString (dn, string, 0);
return string;
}
char *
-decNumberToEngString (decNumber * dn, char *string)
+decNumberToEngString (const decNumber * dn, char *string)
{
decToString (dn, string, 1);
return string;
/* If bad syntax is detected, the result will be a quiet NaN. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberFromString (decNumber * dn, char chars[], decContext * set)
+decNumberFromString (decNumber * dn, const char chars[], decContext * set)
{
Int exponent = 0; /* working exponent [assume 0] */
uByte bits = 0; /* working flags [assume +ve] */
Unit *allocres = NULL; /* -> allocated result, iff allocated */
Int need; /* units needed for result */
Int d = 0; /* count of digits found in decimal part */
- char *dotchar = NULL; /* where dot was found */
- char *cfirst; /* -> first character of decimal part */
- char *last = NULL; /* -> last digit of decimal part */
- char *firstexp; /* -> first significant exponent digit */
- char *c; /* work */
+ const char *dotchar = NULL; /* where dot was found */
+ const char *cfirst; /* -> first character of decimal part */
+ const char *last = NULL; /* -> last digit of decimal part */
+ const char *firstexp; /* -> first significant exponent digit */
+ const char *c; /* work */
Unit *up; /* .. */
#if DECDPUN>1
Int i; /* .. */
/* in which case it has the same effect as decNumberMinus. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberAbs (decNumber * res, decNumber * rhs, decContext * set)
+decNumberAbs (decNumber * res, const decNumber * rhs, decContext * set)
{
decNumber dzero; /* for 0 */
uInt status = 0; /* accumulator */
/* ------------------------------------------------------------------ */
/* This just calls the routine shared with Subtract */
decNumber *
-decNumberAdd (decNumber * res, decNumber * lhs, decNumber * rhs,
- decContext * set)
+decNumberAdd (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decAddOp (res, lhs, rhs, set, 0, &status);
/* C must have space for one digit. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberCompare (decNumber * res, decNumber * lhs, decNumber * rhs,
- decContext * set)
+decNumberCompare (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decCompareOp (res, lhs, rhs, set, COMPARE, &status);
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberDivide (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberDivide (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decDivideOp (res, lhs, rhs, set, DIVIDE, &status);
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberDivideInteger (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberDivideInteger (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decDivideOp (res, lhs, rhs, set, DIVIDEINT, &status);
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberMax (decNumber * res, decNumber * lhs, decNumber * rhs,
- decContext * set)
+decNumberMax (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decCompareOp (res, lhs, rhs, set, COMPMAX, &status);
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberMin (decNumber * res, decNumber * lhs, decNumber * rhs,
- decContext * set)
+decNumberMin (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decCompareOp (res, lhs, rhs, set, COMPMIN, &status);
/* We simply use AddOp for the subtract, which will do the necessary. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberMinus (decNumber * res, decNumber * rhs, decContext * set)
+decNumberMinus (decNumber * res, const decNumber * rhs, decContext * set)
{
decNumber dzero;
uInt status = 0; /* accumulator */
/* check operands and apply rounding and overflow/underflow testing. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberPlus (decNumber * res, decNumber * rhs, decContext * set)
+decNumberPlus (decNumber * res, const decNumber * rhs, decContext * set)
{
decNumber dzero;
uInt status = 0; /* accumulator */
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberMultiply (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberMultiply (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decMultiplyOp (res, lhs, rhs, set, &status);
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberNormalize (decNumber * res, decNumber * rhs, decContext * set)
+decNumberNormalize (decNumber * res, const decNumber * rhs, decContext * set)
{
decNumber *allocrhs = NULL; /* non-NULL if rounded rhs allocated */
uInt status = 0; /* as usual */
/* 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 */
/* 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)
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
/* after the operation is guaranteed to be equal to that of B. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberQuantize (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberQuantize (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decQuantizeOp (res, lhs, rhs, set, 1, &status);
/* after the operation is guaranteed to be equal to B. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberRescale (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberRescale (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decQuantizeOp (res, lhs, rhs, set, 0, &status);
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberRemainder (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberRemainder (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decDivideOp (res, lhs, rhs, set, REMAINDER, &status);
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberRemainderNear (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberRemainderNear (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decDivideOp (res, lhs, rhs, set, REMNEAR, &status);
/* No errors are possible and no context is needed. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberSameQuantum (decNumber * res, decNumber * lhs, decNumber * rhs)
+decNumberSameQuantum (decNumber * res, const decNumber * lhs, const decNumber * rhs)
{
uByte merged; /* merged flags */
Unit ret = 0; /* return value */
/* end sqrt */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberSquareRoot (decNumber * res, decNumber * rhs, decContext * set)
+decNumberSquareRoot (decNumber * res, const decNumber * rhs, decContext * set)
{
decContext workset, approxset; /* work contexts */
decNumber dzero; /* used for constant zero */
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberSubtract (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberSubtract (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
/* the digits setting is ignored. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberToIntegralValue (decNumber * res, decNumber * rhs, decContext * set)
+decNumberToIntegralValue (decNumber * res, const decNumber * rhs, decContext * set)
{
decNumber dn;
decContext workset; /* working context */
/* so special values are unchanged and no error is possible. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberCopy (decNumber * dest, decNumber * src)
+decNumberCopy (decNumber * dest, const decNumber * src)
{
#if DECCHECK
dest->lsu[0] = src->lsu[0];
if (src->digits > DECDPUN)
{ /* more Units to come */
- Unit *s, *d, *smsup; /* work */
+ Unit *d; /* work */
+ const Unit *s, *smsup; /* work */
/* memcpy for the remaining Units would be safe as they cannot */
/* overlap. However, this explicit loop is faster in short cases. */
d = dest->lsu + 1; /* -> first destination */
}
static void
-decToString (decNumber * dn, char *string, Flag eng)
+decToString (const decNumber * dn, char *string, Flag eng)
{
Int exp = dn->exponent; /* local copy */
Int e; /* E-part value */
Int pre; /* digits before the '.' */
Int cut; /* for counting digits in a Unit */
char *c = string; /* work [output pointer] */
- Unit *up = dn->lsu + D2U (dn->digits) - 1; /* -> msu [input pointer] */
+ const Unit *up = dn->lsu + D2U (dn->digits) - 1; /* -> msu [input pointer] */
uInt u, pow; /* work */
#if DECCHECK
/* to make returning as fast as possible, by flagging any allocation. */
/* ------------------------------------------------------------------ */
static decNumber *
-decAddOp (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set, uByte negate, uInt * status)
+decAddOp (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set, uByte negate, uInt * status)
{
decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */
decNumber *allocrhs = NULL; /* .., rhs */
Flag swapped = 0;
if (padding < 0)
{ /* LHS needs the padding */
- decNumber *t;
+ const decNumber *t;
padding = -padding; /* will be +ve */
bits = (uByte) (rhs->bits ^ negate); /* assumed sign is now that of RHS */
t = lhs;
/* ------------------------------------------------------------------ */
static decNumber *
decDivideOp (decNumber * res,
- decNumber * lhs, decNumber * rhs,
+ const decNumber * lhs, const decNumber * rhs,
decContext * set, Flag op, uInt * status)
{
decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */
Unit *var1 = varbuff; /* -> var1 array for long subtraction */
Unit *varalloc = NULL; /* -> allocated buffer, iff used */
- Unit *var2; /* -> var2 array */
+ const Unit *var2; /* -> var2 array */
Int var1units, var2units; /* actual lengths */
Int var2ulen; /* logical length (units) */
Int var1initpad = 0; /* var1 initial padding (digits) */
- Unit *msu1, *msu2; /* -> msu of each var */
+ Unit *msu1; /* -> msu of each var */
+ const Unit *msu2; /* -> msu of each var */
Int msu2plus; /* msu2 plus one [does not vary] */
eInt msu2pair; /* msu2 pair plus one [does not vary] */
Int maxdigits; /* longest LHS or required acc length */
Int maxexponent = 0; /* DIVIDE maximum exponent if unrounded */
uByte bits; /* working sign */
uByte merged; /* merged flags */
- Unit *target, *source; /* work */
+ Unit *target; /* work */
+ const Unit *source; /* work */
uInt const *pow; /* .. */
Int shift, cut; /* .. */
#if DECSUBSET
if (var1units == var2ulen)
{ /* unit-by-unit compare needed */
/* compare the two numbers, from msu */
- Unit *pv1, *pv2, v2; /* units to compare */
+ Unit *pv1, v2; /* units to compare */
+ const Unit *pv2; /* units to compare */
pv2 = msu2; /* -> msu */
for (pv1 = msu1;; pv1--, pv2--)
{
/* We always have to use a buffer for the accumulator. */
/* ------------------------------------------------------------------ */
static decNumber *
-decMultiplyOp (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set, uInt * status)
+decMultiplyOp (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set, uInt * status)
{
decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */
decNumber *allocrhs = NULL; /* .., rhs */
Unit accbuff[D2U (DECBUFFER * 2 + 1)]; /* local buffer (+1 in case DECBUFFER==0) */
Unit *acc = accbuff; /* -> accumulator array for exact result */
Unit *allocacc = NULL; /* -> allocated buffer, iff allocated */
- Unit *mer, *mermsup; /* work */
+ const Unit *mer, *mermsup; /* work */
Int accunits; /* Units of accumulator in use */
Int madlength; /* Units in multiplicand */
Int shift; /* Units to shift multiplicand by */
/* multiplier (rhs) and the longer as the multiplicand (lhs) */
if (lhs->digits < rhs->digits)
{ /* swap... */
- decNumber *hold = lhs;
+ const decNumber *hold = lhs;
lhs = rhs;
rhs = hold;
}
/* after the operation is guaranteed to be that requested. */
/* ------------------------------------------------------------------ */
static decNumber *
-decQuantizeOp (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set, Flag quant, uInt * status)
+decQuantizeOp (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set, Flag quant, uInt * status)
{
decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */
decNumber *allocrhs = NULL; /* .., rhs */
- decNumber *inrhs = rhs; /* save original rhs */
+ const decNumber *inrhs = rhs; /* save original rhs */
Int reqdigits = set->digits; /* requested DIGITS */
Int reqexp; /* requested exponent [-scale] */
Int residue = 0; /* rounding residue */
/* coefficient comparison if possible. */
/* ------------------------------------------------------------------ */
decNumber *
-decCompareOp (decNumber * res, decNumber * lhs, decNumber * rhs,
+decCompareOp (decNumber * res, const decNumber * lhs, const decNumber * rhs,
decContext * set, Flag op, uInt * status)
{
decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */
{ /* MAX or MIN, non-NaN result */
Int residue = 0; /* rounding accumulator */
/* choose the operand for the result */
- decNumber *choice;
+ const decNumber *choice;
if (result == 0)
{ /* operands are numerically equal */
/* choose according to sign then exponent (see 754r) */
/* ------------------------------------------------------------------ */
/* This could be merged into decCompareOp */
static Int
-decCompare (decNumber * lhs, decNumber * rhs)
+decCompare (const decNumber * lhs, const decNumber * rhs)
{
Int result; /* result value */
Int sigr; /* rhs signum */
if (lhs->exponent > rhs->exponent)
{ /* LHS exponent larger */
/* swap sides, and sign */
- decNumber *temp = lhs;
+ const decNumber *temp = lhs;
lhs = rhs;
rhs = temp;
result = -result;
/* (the only possible failure is an allocation error) */
/* ------------------------------------------------------------------ */
static Int
-decUnitCompare (Unit * a, Int alength, Unit * b, Int blength, Int exp)
+decUnitCompare (const Unit * a, Int alength, const Unit * b, Int blength, Int exp)
{
Unit *acc; /* accumulator for result */
Unit accbuff[D2U (DECBUFFER + 1)]; /* local buffer */
Unit *allocacc = NULL; /* -> allocated acc buffer, iff allocated */
Int accunits, need; /* units in use or needed for acc */
- Unit *l, *r, *u; /* work */
+ const Unit *l, *r, *u; /* work */
Int expunits, exprem, result; /* .. */
if (exp == 0)
/* (IBM Warwick, UK) for some of the ideas used in this routine. */
/* ------------------------------------------------------------------ */
static Int
-decUnitAddSub (Unit * a, Int alength,
- Unit * b, Int blength, Int bshift, Unit * c, Int m)
+decUnitAddSub (const Unit * a, Int alength,
+ const Unit * b, Int blength, Int bshift, Unit * c, Int m)
{
- Unit *alsu = a; /* A lsu [need to remember it] */
+ const Unit *alsu = a; /* A lsu [need to remember it] */
Unit *clsu = c; /* C ditto */
Unit *minC; /* low water mark for C */
Unit *maxC; /* high water mark for C */
/* is returned. */
/* ------------------------------------------------------------------ */
static decNumber *
-decRoundOperand (decNumber * dn, decContext * set, uInt * status)
+decRoundOperand (const decNumber * dn, decContext * set, uInt * status)
{
decNumber *res; /* result structure */
uInt newstatus = 0; /* status from round */
/* All fields are updated as required. */
/* ------------------------------------------------------------------ */
static void
-decCopyFit (decNumber * dest, decNumber * src, decContext * set,
+decCopyFit (decNumber * dest, const decNumber * src, decContext * set,
Int * residue, uInt * status)
{
dest->bits = src->bits;
/* 0 1 2 3 4 5 6 7 8 9 */
static const uByte resmap[10] = { 0, 3, 3, 3, 3, 5, 7, 7, 7, 7 };
static void
-decSetCoeff (decNumber * dn, decContext * set, Unit * lsu,
+decSetCoeff (decNumber * dn, decContext * set, const Unit * lsu,
Int len, Int * residue, uInt * status)
{
Int discard; /* number of digits to discard */
uInt discard1; /* first discarded digit */
uInt cut; /* cut point in Unit */
uInt quot, rem; /* for divisions */
- Unit *up, *target; /* work */
+ Unit *target; /* work */
+ const Unit *up; /* work */
Int count; /* .. */
#if DECDPUN<=4
uInt temp; /* .. */
/* necessary. Underflow is set if the result is Inexact. */
/* ------------------------------------------------------------------ */
static void
-decSetSubnormal (decNumber * dn, decContext * set, Int * residue,
- uInt * status)
+decSetSubnormal (decNumber * dn, decContext * set,
+ Int * residue, uInt * status)
{
decContext workset; /* work */
Int etiny, adjust; /* .. */
/* ------------------------------------------------------------------ */
#if DECSUBSET
static Int
-decGetInt (decNumber * dn, decContext * set)
+decGetInt (const decNumber * dn, decContext * set)
{
#else
static Int
-decGetInt (decNumber * dn)
+decGetInt (const decNumber * dn)
{
#endif
Int theInt; /* result accumulator */
- Unit *up; /* work */
+ const Unit *up; /* work */
Int got; /* digits (real or not) processed */
Int ilength = dn->digits + dn->exponent; /* integral length */
/* to a qNaN and Invalid operation is set. */
/* ------------------------------------------------------------------ */
static decNumber *
-decNaNs (decNumber * res, decNumber * lhs, decNumber * rhs, uInt * status)
+decNaNs (decNumber * res, const decNumber * lhs, const decNumber * rhs, uInt * status)
{
/* This decision tree ends up with LHS being the source pointer, */
/* and status updated if need be */
/* ------------------------------------------------------------------ */
/* This may be called twice during some operations. */
static Int
-decGetDigits (Unit * uar, Int len)
+decGetDigits (const Unit * uar, Int len)
{
- Unit *up = uar + len - 1; /* -> msu */
+ const Unit *up = uar + len - 1; /* -> msu */
Int digits = len * DECDPUN; /* maximum possible digits */
uInt const *pow; /* work */
/* ------------------------------------------------------------------ */
/* this is public so other modules can use it */
void
-decNumberShow (decNumber * dn)
+decNumberShow (const decNumber * dn)
{
- Unit *up; /* work */
+ const Unit *up; /* work */
uInt u, d; /* .. */
Int cut; /* .. */
char isign = '+'; /* main sign */
/* len is the length of the array in Units */
/* ------------------------------------------------------------------ */
static void
-decDumpAr (char name, Unit * ar, Int len)
+decDumpAr (char name, const Unit * ar, Int len)
{
Int i;
#if DECDPUN==4
- char *spec = "%04d ";
+ const char *spec = "%04d ";
#else
- char *spec = "%d ";
+ const char *spec = "%d ";
#endif
printf (" :%c: ", name);
for (i = len - 1; i >= 0; i--)
/* The caller is expected to abandon immediately if 1 is returned. */
/* ------------------------------------------------------------------ */
static Flag
-decCheckOperands (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decCheckOperands (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
Flag bad = 0;
if (set == NULL)
/* operation in some valid context (not necessarily the current one). */
/* ------------------------------------------------------------------ */
Flag
-decCheckNumber (decNumber * dn, decContext * set)
+decCheckNumber (const decNumber * dn, decContext * set)
{
- Unit *up; /* work */
+ const Unit *up; /* work */
uInt maxuint; /* .. */
Int ae, d, digits; /* .. */
Int emin, emax; /* .. */