Commit aa4f41c1 by Kaveh R. Ghazi Committed by Kaveh Ghazi

configure.ac (ACX_PROG_CC_WARNING_OPTS): Add -Wcast-qual.

	* configure.ac (ACX_PROG_CC_WARNING_OPTS): Add -Wcast-qual.
	* configure, config.in: Regenerate.

	* decContext.c (decContextStatusToString): Constify.
	* decContext.h (decContextStatusToString): Likewise.
	* decNumber.c (decNumberToString, decNumberToEngString,
	decNumberAbs, decNumberAdd, decNumberCompare, decNumberDivide,
	decNumberDivideInteger, decNumberMax, decNumberMin,
	decNumberMinus, decNumberPlus, decNumberMultiply,
	decNumberNormalize, decNumberQuantize, decNumberRescale,
	 decNumberRemainder, decNumberRemainderNear,
	decNumberSameQuantum, decNumberSquareRoot, decNumberSubtract,
	decNumberToIntegralValue, decNumberCopy, decToString, decAddOp,
	decDivideOp, decMultiplyOp, decQuantizeOp, decCompareOp,
	decCompare, decUnitCompare, decUnitAddSub, decRoundOperand,
	decCopyFit, decSetCoeff, decGetInt, decNaNs, decGetDigits,
	decNumberShow, decDumpAr, decCheckOperands, decCheckNumber):
	Likewise.
	* decNumber.h (decNumberToString, decNumberToEngString,
	decNumberAbs, decNumberAdd, decNumberCompare, decNumberDivide,
	decNumberDivideInteger, decNumberMax, decNumberMin,
	decNumberMinus, decNumberMultiply, decNumberNormalize,
	decNumberPlus, decNumberQuantize, decNumberRemainder,
	 decNumberRemainderNear, decNumberRescale,
	decNumberSameQuantum, decNumberSquareRoot, decNumberSubtract,
	decNumberToIntegralValue, decNumberCopy): Likewise.
	* decUtility.c (decDensePackCoeff, decDenseUnpackCoeff):
	Likewise.
	* decUtility.h (decDensePackCoeff, decDenseUnpackCoeff):
	Likewise.
	* decimal128.c (decimal128FromNumber, decimal128ToNumber,
	decimal128ToString, decimal128ToEngString, decimal128Show):
	Likewise.
	* decimal128.h (decimal128ToString, decimal128ToEngString,
	decimal128FromNumber, decimal128ToNumber): Likewise.
	* decimal32.c (decimal32FromNumber, decimal32ToNumber,
	decimal32ToString, decimal32ToEngString, decimal32Show):
	Likewise.
	* decimal32.h (decimal32ToString, decimal32ToEngString,
	decimal32FromNumber, decimal32ToNumber): Likewise.
	* decimal64.c (decimal64FromNumber, decimal64ToNumber,
	decimal64ToString, decimal64ToEngString, decimal64Show):
	Likewise.
	* decimal64.h (decimal64ToString, decimal64ToEngString,
	decimal64FromNumber, decimal64ToNumber): Likewise.

From-SVN: r116738
parent c08cd4c1
2006-09-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* configure.ac (ACX_PROG_CC_WARNING_OPTS): Add -Wcast-qual.
* configure, config.in: Regenerate.
* decContext.c (decContextStatusToString): Constify.
* decContext.h (decContextStatusToString): Likewise.
* decNumber.c (decNumberToString, decNumberToEngString,
decNumberAbs, decNumberAdd, decNumberCompare, decNumberDivide,
decNumberDivideInteger, decNumberMax, decNumberMin,
decNumberMinus, decNumberPlus, decNumberMultiply,
decNumberNormalize, decNumberQuantize, decNumberRescale,
decNumberRemainder, decNumberRemainderNear,
decNumberSameQuantum, decNumberSquareRoot, decNumberSubtract,
decNumberToIntegralValue, decNumberCopy, decToString, decAddOp,
decDivideOp, decMultiplyOp, decQuantizeOp, decCompareOp,
decCompare, decUnitCompare, decUnitAddSub, decRoundOperand,
decCopyFit, decSetCoeff, decGetInt, decNaNs, decGetDigits,
decNumberShow, decDumpAr, decCheckOperands, decCheckNumber):
Likewise.
* decNumber.h (decNumberToString, decNumberToEngString,
decNumberAbs, decNumberAdd, decNumberCompare, decNumberDivide,
decNumberDivideInteger, decNumberMax, decNumberMin,
decNumberMinus, decNumberMultiply, decNumberNormalize,
decNumberPlus, decNumberQuantize, decNumberRemainder,
decNumberRemainderNear, decNumberRescale,
decNumberSameQuantum, decNumberSquareRoot, decNumberSubtract,
decNumberToIntegralValue, decNumberCopy): Likewise.
* decUtility.c (decDensePackCoeff, decDenseUnpackCoeff):
Likewise.
* decUtility.h (decDensePackCoeff, decDenseUnpackCoeff):
Likewise.
* decimal128.c (decimal128FromNumber, decimal128ToNumber,
decimal128ToString, decimal128ToEngString, decimal128Show):
Likewise.
* decimal128.h (decimal128ToString, decimal128ToEngString,
decimal128FromNumber, decimal128ToNumber): Likewise.
* decimal32.c (decimal32FromNumber, decimal32ToNumber,
decimal32ToString, decimal32ToEngString, decimal32Show):
Likewise.
* decimal32.h (decimal32ToString, decimal32ToEngString,
decimal32FromNumber, decimal32ToNumber): Likewise.
* decimal64.c (decimal64FromNumber, decimal64ToNumber,
decimal64ToString, decimal64ToEngString, decimal64Show):
Likewise.
* decimal64.h (decimal64ToString, decimal64ToEngString,
decimal64FromNumber, decimal64ToNumber): Likewise.
2006-08-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2006-08-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* decContext.c (decContextSetStatusFromString): Constify. * decContext.c (decContextSetStatusFromString): Constify.
......
/* config.in. Generated from configure.ac by autoheader. */ /* config.in. Generated from configure.ac by autoheader. */
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
#undef CRAY_STACKSEG_END
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
#undef HAVE_ALLOCA_H
/* Define to 1 if you have the <ctype.h> header file. */ /* Define to 1 if you have the <ctype.h> header file. */
#undef HAVE_CTYPE_H #undef HAVE_CTYPE_H
...@@ -66,26 +51,24 @@ ...@@ -66,26 +51,24 @@
/* Define to the version of this package. */ /* Define to the version of this package. */
#undef PACKAGE_VERSION #undef PACKAGE_VERSION
/* The size of a `char', as computed by sizeof. */
#undef SIZEOF_CHAR
/* The size of a `int', as computed by sizeof. */ /* The size of a `int', as computed by sizeof. */
#undef SIZEOF_INT #undef SIZEOF_INT
/* The size of a `long', as computed by sizeof. */ /* The size of a `long', as computed by sizeof. */
#undef SIZEOF_LONG #undef SIZEOF_LONG
/* If using the C implementation of alloca, define if you know the /* The size of a `short', as computed by sizeof. */
direction of stack growth for your system; otherwise it will be #undef SIZEOF_SHORT
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses /* The size of a `void *', as computed by sizeof. */
STACK_DIRECTION < 0 => grows toward lower addresses #undef SIZEOF_VOID_P
STACK_DIRECTION = 0 => direction of growth unknown */
#undef STACK_DIRECTION
/* Define to 1 if you have the ANSI C header files. */ /* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS #undef STDC_HEADERS
/* Define if you can safely include both <string.h> and <strings.h>. */
#undef STRING_WITH_STRINGS
/* Define to empty if `const' does not conform to ANSI C. */ /* Define to empty if `const' does not conform to ANSI C. */
#undef const #undef const
......
...@@ -2492,7 +2492,7 @@ WARN_CFLAGS= ...@@ -2492,7 +2492,7 @@ WARN_CFLAGS=
save_CFLAGS="$CFLAGS" save_CFLAGS="$CFLAGS"
for option in -W -Wall -Wwrite-strings -Wstrict-prototypes \ for option in -W -Wall -Wwrite-strings -Wstrict-prototypes \
-Wmissing-prototypes -Wold-style-definition \ -Wmissing-prototypes -Wold-style-definition \
-Wmissing-format-attribute; do -Wmissing-format-attribute -Wcast-qual; do
as_acx_Woption=`echo "acx_cv_prog_cc_warning_$option" | $as_tr_sh` as_acx_Woption=`echo "acx_cv_prog_cc_warning_$option" | $as_tr_sh`
echo "$as_me:$LINENO: checking whether $CC supports $option" >&5 echo "$as_me:$LINENO: checking whether $CC supports $option" >&5
......
...@@ -40,7 +40,7 @@ AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader]) ...@@ -40,7 +40,7 @@ AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader])
ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \ ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
-Wmissing-prototypes -Wold-style-definition \ -Wmissing-prototypes -Wold-style-definition \
-Wmissing-format-attribute]) -Wmissing-format-attribute -Wcast-qual])
ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long]) ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long])
# Only enable with --enable-werror-always until existing warnings are # Only enable with --enable-werror-always until existing warnings are
......
...@@ -109,7 +109,7 @@ decContextDefault (decContext * context, Int kind) ...@@ -109,7 +109,7 @@ decContextDefault (decContext * context, Int kind)
/* (or no) flags are set, a generic constant message is returned. */ /* (or no) flags are set, a generic constant message is returned. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
const char * const char *
decContextStatusToString (decContext * context) decContextStatusToString (const decContext * context)
{ {
Int status = context->status; Int status = context->status;
if (status == DEC_Conversion_syntax) if (status == DEC_Conversion_syntax)
......
...@@ -172,7 +172,7 @@ typedef struct ...@@ -172,7 +172,7 @@ typedef struct
#endif #endif
decContext *decContextDefault (decContext *, int32_t); decContext *decContextDefault (decContext *, int32_t);
decContext *decContextSetStatus (decContext *, uint32_t); decContext *decContextSetStatus (decContext *, uint32_t);
const char *decContextStatusToString (decContext *); const char *decContextStatusToString (const decContext *);
decContext *decContextSetStatusFromString (decContext *, const char *); decContext *decContextSetStatusFromString (decContext *, const char *);
#endif #endif
...@@ -206,29 +206,30 @@ typedef unsigned long long uLong; ...@@ -206,29 +206,30 @@ typedef unsigned long long uLong;
#endif #endif
/* Local routines */ /* Local routines */
static decNumber *decAddOp (decNumber *, decNumber *, decNumber *, static decNumber *decAddOp (decNumber *, const decNumber *,
decContext *, uByte, uInt *); const decNumber *, decContext *,
uByte, uInt *);
static void decApplyRound (decNumber *, decContext *, Int, uInt *); static void decApplyRound (decNumber *, decContext *, Int, uInt *);
static Int decCompare (decNumber * lhs, decNumber * rhs); static Int decCompare (const decNumber * lhs, const decNumber * rhs);
static decNumber *decCompareOp (decNumber *, decNumber *, decNumber *, static decNumber *decCompareOp (decNumber *, const decNumber *, const decNumber *,
decContext *, Flag, uInt *); decContext *, Flag, uInt *);
static void decCopyFit (decNumber *, decNumber *, decContext *, static void decCopyFit (decNumber *, const decNumber *, decContext *,
Int *, uInt *); Int *, uInt *);
static decNumber *decDivideOp (decNumber *, decNumber *, decNumber *, static decNumber *decDivideOp (decNumber *, const decNumber *, const decNumber *,
decContext *, Flag, uInt *); decContext *, Flag, uInt *);
static void decFinalize (decNumber *, decContext *, Int *, uInt *); static void decFinalize (decNumber *, decContext *, Int *, uInt *);
static Int decGetDigits (Unit *, Int); static Int decGetDigits (const Unit *, Int);
#if DECSUBSET #if DECSUBSET
static Int decGetInt (decNumber *, decContext *); static Int decGetInt (const decNumber *, decContext *);
#else #else
static Int decGetInt (decNumber *); static Int decGetInt (const decNumber *);
#endif #endif
static decNumber *decMultiplyOp (decNumber *, decNumber *, decNumber *, static decNumber *decMultiplyOp (decNumber *, const decNumber *,
decContext *, uInt *); const decNumber *, decContext *, uInt *);
static decNumber *decNaNs (decNumber *, decNumber *, decNumber *, uInt *); static decNumber *decNaNs (decNumber *, const decNumber *, const decNumber *, uInt *);
static decNumber *decQuantizeOp (decNumber *, decNumber *, decNumber *, static decNumber *decQuantizeOp (decNumber *, const decNumber *,
decContext *, Flag, uInt *); const decNumber *, decContext *, Flag, uInt *);
static void decSetCoeff (decNumber *, decContext *, Unit *, static void decSetCoeff (decNumber *, decContext *, const Unit *,
Int, Int *, uInt *); Int, Int *, uInt *);
static void decSetOverflow (decNumber *, decContext *, uInt *); static void decSetOverflow (decNumber *, decContext *, uInt *);
static void decSetSubnormal (decNumber *, decContext *, Int *, uInt *); static void decSetSubnormal (decNumber *, decContext *, Int *, uInt *);
...@@ -236,17 +237,17 @@ static Int decShiftToLeast (Unit *, Int, Int); ...@@ -236,17 +237,17 @@ static Int decShiftToLeast (Unit *, Int, Int);
static Int decShiftToMost (Unit *, Int, Int); static Int decShiftToMost (Unit *, Int, Int);
static void decStatus (decNumber *, uInt, decContext *); static void decStatus (decNumber *, uInt, decContext *);
static Flag decStrEq (const char *, const char *); 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 decNumber *decTrim (decNumber *, Flag, Int *);
static Int decUnitAddSub (Unit *, Int, Unit *, Int, Int, Unit *, Int); static Int decUnitAddSub (const Unit *, Int, const Unit *, Int, Int, Unit *, Int);
static Int decUnitCompare (Unit *, Int, Unit *, Int, Int); static Int decUnitCompare (const Unit *, Int, const Unit *, Int, Int);
#if !DECSUBSET #if !DECSUBSET
/* decFinish == decFinalize when no subset arithmetic needed */ /* decFinish == decFinalize when no subset arithmetic needed */
#define decFinish(a,b,c,d) decFinalize(a,b,c,d) #define decFinish(a,b,c,d) decFinalize(a,b,c,d)
#else #else
static void decFinish (decNumber *, decContext *, Int *, uInt *); static void decFinish (decNumber *, decContext *, Int *, uInt *);
static decNumber *decRoundOperand (decNumber *, decContext *, uInt *); static decNumber *decRoundOperand (const decNumber *, decContext *, uInt *);
#endif #endif
/* Diagnostic macros, etc. */ /* Diagnostic macros, etc. */
...@@ -275,15 +276,15 @@ uInt decAllocBytes = 0; /* count of bytes allocated */ ...@@ -275,15 +276,15 @@ uInt decAllocBytes = 0; /* count of bytes allocated */
/* fastest routines (and adds 600+ bytes), so should not normally be */ /* fastest routines (and adds 600+ bytes), so should not normally be */
/* used in 'production'. */ /* used in 'production'. */
#define DECUNUSED (void *)(0xffffffff) #define DECUNUSED (void *)(0xffffffff)
static Flag decCheckOperands (decNumber *, decNumber *, decNumber *, static Flag decCheckOperands (decNumber *, const decNumber *,
decContext *); const decNumber *, decContext *);
static Flag decCheckNumber (decNumber *, decContext *); static Flag decCheckNumber (const decNumber *, decContext *);
#endif #endif
#if DECTRACE || DECCHECK #if DECTRACE || DECCHECK
/* Optional trace/debugging routines. */ /* Optional trace/debugging routines. */
void decNumberShow (decNumber *); /* displays the components of a number */ void decNumberShow (const decNumber *); /* displays the components of a number */
static void decDumpAr (char, Unit *, Int); static void decDumpAr (char, const Unit *, Int);
#endif #endif
/* ================================================================== */ /* ================================================================== */
...@@ -305,14 +306,14 @@ static void decDumpAr (char, Unit *, Int); ...@@ -305,14 +306,14 @@ static void decDumpAr (char, Unit *, Int);
/* No error is possible, and no status can be set. */ /* No error is possible, and no status can be set. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
char * char *
decNumberToString (decNumber * dn, char *string) decNumberToString (const decNumber * dn, char *string)
{ {
decToString (dn, string, 0); decToString (dn, string, 0);
return string; return string;
} }
char * char *
decNumberToEngString (decNumber * dn, char *string) decNumberToEngString (const decNumber * dn, char *string)
{ {
decToString (dn, string, 1); decToString (dn, string, 1);
return string; return string;
...@@ -640,7 +641,7 @@ decNumberFromString (decNumber * dn, const char chars[], decContext * set) ...@@ -640,7 +641,7 @@ decNumberFromString (decNumber * dn, const char chars[], decContext * set)
/* in which case it has the same effect as decNumberMinus. */ /* in which case it has the same effect as decNumberMinus. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberAbs (decNumber * res, decNumber * rhs, decContext * set) decNumberAbs (decNumber * res, const decNumber * rhs, decContext * set)
{ {
decNumber dzero; /* for 0 */ decNumber dzero; /* for 0 */
uInt status = 0; /* accumulator */ uInt status = 0; /* accumulator */
...@@ -672,8 +673,8 @@ decNumberAbs (decNumber * res, decNumber * rhs, decContext * set) ...@@ -672,8 +673,8 @@ decNumberAbs (decNumber * res, decNumber * rhs, decContext * set)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* This just calls the routine shared with Subtract */ /* This just calls the routine shared with Subtract */
decNumber * decNumber *
decNumberAdd (decNumber * res, decNumber * lhs, decNumber * rhs, decNumberAdd (decNumber * res, const decNumber * lhs,
decContext * set) const decNumber * rhs, decContext * set)
{ {
uInt status = 0; /* accumulator */ uInt status = 0; /* accumulator */
decAddOp (res, lhs, rhs, set, 0, &status); decAddOp (res, lhs, rhs, set, 0, &status);
...@@ -695,8 +696,8 @@ decNumberAdd (decNumber * res, decNumber * lhs, decNumber * rhs, ...@@ -695,8 +696,8 @@ decNumberAdd (decNumber * res, decNumber * lhs, decNumber * rhs,
/* C must have space for one digit. */ /* C must have space for one digit. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberCompare (decNumber * res, decNumber * lhs, decNumber * rhs, decNumberCompare (decNumber * res, const decNumber * lhs,
decContext * set) const decNumber * rhs, decContext * set)
{ {
uInt status = 0; /* accumulator */ uInt status = 0; /* accumulator */
decCompareOp (res, lhs, rhs, set, COMPARE, &status); decCompareOp (res, lhs, rhs, set, COMPARE, &status);
...@@ -718,8 +719,8 @@ decNumberCompare (decNumber * res, decNumber * lhs, decNumber * rhs, ...@@ -718,8 +719,8 @@ decNumberCompare (decNumber * res, decNumber * lhs, decNumber * rhs,
/* C must have space for set->digits digits. */ /* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberDivide (decNumber * res, decNumber * lhs, decNumberDivide (decNumber * res, const decNumber * lhs,
decNumber * rhs, decContext * set) const decNumber * rhs, decContext * set)
{ {
uInt status = 0; /* accumulator */ uInt status = 0; /* accumulator */
decDivideOp (res, lhs, rhs, set, DIVIDE, &status); decDivideOp (res, lhs, rhs, set, DIVIDE, &status);
...@@ -741,8 +742,8 @@ decNumberDivide (decNumber * res, decNumber * lhs, ...@@ -741,8 +742,8 @@ decNumberDivide (decNumber * res, decNumber * lhs,
/* C must have space for set->digits digits. */ /* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberDivideInteger (decNumber * res, decNumber * lhs, decNumberDivideInteger (decNumber * res, const decNumber * lhs,
decNumber * rhs, decContext * set) const decNumber * rhs, decContext * set)
{ {
uInt status = 0; /* accumulator */ uInt status = 0; /* accumulator */
decDivideOp (res, lhs, rhs, set, DIVIDEINT, &status); decDivideOp (res, lhs, rhs, set, DIVIDEINT, &status);
...@@ -764,8 +765,8 @@ decNumberDivideInteger (decNumber * res, decNumber * lhs, ...@@ -764,8 +765,8 @@ decNumberDivideInteger (decNumber * res, decNumber * lhs,
/* C must have space for set->digits digits. */ /* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberMax (decNumber * res, decNumber * lhs, decNumber * rhs, decNumberMax (decNumber * res, const decNumber * lhs,
decContext * set) const decNumber * rhs, decContext * set)
{ {
uInt status = 0; /* accumulator */ uInt status = 0; /* accumulator */
decCompareOp (res, lhs, rhs, set, COMPMAX, &status); decCompareOp (res, lhs, rhs, set, COMPMAX, &status);
...@@ -787,8 +788,8 @@ decNumberMax (decNumber * res, decNumber * lhs, decNumber * rhs, ...@@ -787,8 +788,8 @@ decNumberMax (decNumber * res, decNumber * lhs, decNumber * rhs,
/* C must have space for set->digits digits. */ /* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberMin (decNumber * res, decNumber * lhs, decNumber * rhs, decNumberMin (decNumber * res, const decNumber * lhs,
decContext * set) const decNumber * rhs, decContext * set)
{ {
uInt status = 0; /* accumulator */ uInt status = 0; /* accumulator */
decCompareOp (res, lhs, rhs, set, COMPMIN, &status); decCompareOp (res, lhs, rhs, set, COMPMIN, &status);
...@@ -811,7 +812,7 @@ decNumberMin (decNumber * res, decNumber * lhs, decNumber * rhs, ...@@ -811,7 +812,7 @@ decNumberMin (decNumber * res, decNumber * lhs, decNumber * rhs,
/* We simply use AddOp for the subtract, which will do the necessary. */ /* We simply use AddOp for the subtract, which will do the necessary. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberMinus (decNumber * res, decNumber * rhs, decContext * set) decNumberMinus (decNumber * res, const decNumber * rhs, decContext * set)
{ {
decNumber dzero; decNumber dzero;
uInt status = 0; /* accumulator */ uInt status = 0; /* accumulator */
...@@ -845,7 +846,7 @@ decNumberMinus (decNumber * res, decNumber * rhs, decContext * set) ...@@ -845,7 +846,7 @@ decNumberMinus (decNumber * res, decNumber * rhs, decContext * set)
/* check operands and apply rounding and overflow/underflow testing. */ /* check operands and apply rounding and overflow/underflow testing. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberPlus (decNumber * res, decNumber * rhs, decContext * set) decNumberPlus (decNumber * res, const decNumber * rhs, decContext * set)
{ {
decNumber dzero; decNumber dzero;
uInt status = 0; /* accumulator */ uInt status = 0; /* accumulator */
...@@ -876,8 +877,8 @@ decNumberPlus (decNumber * res, decNumber * rhs, decContext * set) ...@@ -876,8 +877,8 @@ decNumberPlus (decNumber * res, decNumber * rhs, decContext * set)
/* C must have space for set->digits digits. */ /* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberMultiply (decNumber * res, decNumber * lhs, decNumberMultiply (decNumber * res, const decNumber * lhs,
decNumber * rhs, decContext * set) const decNumber * rhs, decContext * set)
{ {
uInt status = 0; /* accumulator */ uInt status = 0; /* accumulator */
decMultiplyOp (res, lhs, rhs, set, &status); decMultiplyOp (res, lhs, rhs, set, &status);
...@@ -898,7 +899,7 @@ decNumberMultiply (decNumber * res, decNumber * lhs, ...@@ -898,7 +899,7 @@ decNumberMultiply (decNumber * res, decNumber * lhs,
/* C must have space for set->digits digits. */ /* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * 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 */ decNumber *allocrhs = NULL; /* non-NULL if rounded rhs allocated */
uInt status = 0; /* as usual */ uInt status = 0; /* as usual */
...@@ -1248,8 +1249,8 @@ decNumberPower (decNumber * res, decNumber * lhs, ...@@ -1248,8 +1249,8 @@ decNumberPower (decNumber * res, decNumber * lhs,
/* after the operation is guaranteed to be equal to that of B. */ /* after the operation is guaranteed to be equal to that of B. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberQuantize (decNumber * res, decNumber * lhs, decNumberQuantize (decNumber * res, const decNumber * lhs,
decNumber * rhs, decContext * set) const decNumber * rhs, decContext * set)
{ {
uInt status = 0; /* accumulator */ uInt status = 0; /* accumulator */
decQuantizeOp (res, lhs, rhs, set, 1, &status); decQuantizeOp (res, lhs, rhs, set, 1, &status);
...@@ -1277,8 +1278,8 @@ decNumberQuantize (decNumber * res, decNumber * lhs, ...@@ -1277,8 +1278,8 @@ decNumberQuantize (decNumber * res, decNumber * lhs,
/* after the operation is guaranteed to be equal to B. */ /* after the operation is guaranteed to be equal to B. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberRescale (decNumber * res, decNumber * lhs, decNumberRescale (decNumber * res, const decNumber * lhs,
decNumber * rhs, decContext * set) const decNumber * rhs, decContext * set)
{ {
uInt status = 0; /* accumulator */ uInt status = 0; /* accumulator */
decQuantizeOp (res, lhs, rhs, set, 0, &status); decQuantizeOp (res, lhs, rhs, set, 0, &status);
...@@ -1300,8 +1301,8 @@ decNumberRescale (decNumber * res, decNumber * lhs, ...@@ -1300,8 +1301,8 @@ decNumberRescale (decNumber * res, decNumber * lhs,
/* C must have space for set->digits digits. */ /* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberRemainder (decNumber * res, decNumber * lhs, decNumberRemainder (decNumber * res, const decNumber * lhs,
decNumber * rhs, decContext * set) const decNumber * rhs, decContext * set)
{ {
uInt status = 0; /* accumulator */ uInt status = 0; /* accumulator */
decDivideOp (res, lhs, rhs, set, REMAINDER, &status); decDivideOp (res, lhs, rhs, set, REMAINDER, &status);
...@@ -1323,8 +1324,8 @@ decNumberRemainder (decNumber * res, decNumber * lhs, ...@@ -1323,8 +1324,8 @@ decNumberRemainder (decNumber * res, decNumber * lhs,
/* C must have space for set->digits digits. */ /* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberRemainderNear (decNumber * res, decNumber * lhs, decNumberRemainderNear (decNumber * res, const decNumber * lhs,
decNumber * rhs, decContext * set) const decNumber * rhs, decContext * set)
{ {
uInt status = 0; /* accumulator */ uInt status = 0; /* accumulator */
decDivideOp (res, lhs, rhs, set, REMNEAR, &status); decDivideOp (res, lhs, rhs, set, REMNEAR, &status);
...@@ -1343,7 +1344,7 @@ decNumberRemainderNear (decNumber * res, decNumber * lhs, ...@@ -1343,7 +1344,7 @@ decNumberRemainderNear (decNumber * res, decNumber * lhs,
/* No errors are possible and no context is needed. */ /* No errors are possible and no context is needed. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberSameQuantum (decNumber * res, decNumber * lhs, decNumber * rhs) decNumberSameQuantum (decNumber * res, const decNumber * lhs, const decNumber * rhs)
{ {
uByte merged; /* merged flags */ uByte merged; /* merged flags */
Unit ret = 0; /* return value */ Unit ret = 0; /* return value */
...@@ -1440,7 +1441,7 @@ decNumberSameQuantum (decNumber * res, decNumber * lhs, decNumber * rhs) ...@@ -1440,7 +1441,7 @@ decNumberSameQuantum (decNumber * res, decNumber * lhs, decNumber * rhs)
/* end sqrt */ /* end sqrt */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberSquareRoot (decNumber * res, decNumber * rhs, decContext * set) decNumberSquareRoot (decNumber * res, const decNumber * rhs, decContext * set)
{ {
decContext workset, approxset; /* work contexts */ decContext workset, approxset; /* work contexts */
decNumber dzero; /* used for constant zero */ decNumber dzero; /* used for constant zero */
...@@ -1781,8 +1782,8 @@ decNumberSquareRoot (decNumber * res, decNumber * rhs, decContext * set) ...@@ -1781,8 +1782,8 @@ decNumberSquareRoot (decNumber * res, decNumber * rhs, decContext * set)
/* C must have space for set->digits digits. */ /* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberSubtract (decNumber * res, decNumber * lhs, decNumberSubtract (decNumber * res, const decNumber * lhs,
decNumber * rhs, decContext * set) const decNumber * rhs, decContext * set)
{ {
uInt status = 0; /* accumulator */ uInt status = 0; /* accumulator */
...@@ -1810,7 +1811,7 @@ decNumberSubtract (decNumber * res, decNumber * lhs, ...@@ -1810,7 +1811,7 @@ decNumberSubtract (decNumber * res, decNumber * lhs,
/* the digits setting is ignored. */ /* the digits setting is ignored. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberToIntegralValue (decNumber * res, decNumber * rhs, decContext * set) decNumberToIntegralValue (decNumber * res, const decNumber * rhs, decContext * set)
{ {
decNumber dn; decNumber dn;
decContext workset; /* working context */ decContext workset; /* working context */
...@@ -1860,7 +1861,7 @@ decNumberToIntegralValue (decNumber * res, decNumber * rhs, decContext * set) ...@@ -1860,7 +1861,7 @@ decNumberToIntegralValue (decNumber * res, decNumber * rhs, decContext * set)
/* so special values are unchanged and no error is possible. */ /* so special values are unchanged and no error is possible. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decNumberCopy (decNumber * dest, decNumber * src) decNumberCopy (decNumber * dest, const decNumber * src)
{ {
#if DECCHECK #if DECCHECK
...@@ -1881,7 +1882,8 @@ decNumberCopy (decNumber * dest, decNumber * src) ...@@ -1881,7 +1882,8 @@ decNumberCopy (decNumber * dest, decNumber * src)
dest->lsu[0] = src->lsu[0]; dest->lsu[0] = src->lsu[0];
if (src->digits > DECDPUN) if (src->digits > DECDPUN)
{ /* more Units to come */ { /* 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 */ /* memcpy for the remaining Units would be safe as they cannot */
/* overlap. However, this explicit loop is faster in short cases. */ /* overlap. However, this explicit loop is faster in short cases. */
d = dest->lsu + 1; /* -> first destination */ d = dest->lsu + 1; /* -> first destination */
...@@ -1987,14 +1989,14 @@ decNumberZero (decNumber * dn) ...@@ -1987,14 +1989,14 @@ decNumberZero (decNumber * dn)
} }
static void static void
decToString (decNumber * dn, char *string, Flag eng) decToString (const decNumber * dn, char *string, Flag eng)
{ {
Int exp = dn->exponent; /* local copy */ Int exp = dn->exponent; /* local copy */
Int e; /* E-part value */ Int e; /* E-part value */
Int pre; /* digits before the '.' */ Int pre; /* digits before the '.' */
Int cut; /* for counting digits in a Unit */ Int cut; /* for counting digits in a Unit */
char *c = string; /* work [output pointer] */ 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 */ uInt u, pow; /* work */
#if DECCHECK #if DECCHECK
...@@ -2214,8 +2216,8 @@ decToString (decNumber * dn, char *string, Flag eng) ...@@ -2214,8 +2216,8 @@ decToString (decNumber * dn, char *string, Flag eng)
/* to make returning as fast as possible, by flagging any allocation. */ /* to make returning as fast as possible, by flagging any allocation. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static decNumber * static decNumber *
decAddOp (decNumber * res, decNumber * lhs, decAddOp (decNumber * res, const decNumber * lhs,
decNumber * rhs, decContext * set, uByte negate, uInt * status) const decNumber * rhs, decContext * set, uByte negate, uInt * status)
{ {
decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */ decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */
decNumber *allocrhs = NULL; /* .., rhs */ decNumber *allocrhs = NULL; /* .., rhs */
...@@ -2439,7 +2441,7 @@ decAddOp (decNumber * res, decNumber * lhs, ...@@ -2439,7 +2441,7 @@ decAddOp (decNumber * res, decNumber * lhs,
Flag swapped = 0; Flag swapped = 0;
if (padding < 0) if (padding < 0)
{ /* LHS needs the padding */ { /* LHS needs the padding */
decNumber *t; const decNumber *t;
padding = -padding; /* will be +ve */ padding = -padding; /* will be +ve */
bits = (uByte) (rhs->bits ^ negate); /* assumed sign is now that of RHS */ bits = (uByte) (rhs->bits ^ negate); /* assumed sign is now that of RHS */
t = lhs; t = lhs;
...@@ -2692,7 +2694,7 @@ decAddOp (decNumber * res, decNumber * lhs, ...@@ -2692,7 +2694,7 @@ decAddOp (decNumber * res, decNumber * lhs,
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static decNumber * static decNumber *
decDivideOp (decNumber * res, decDivideOp (decNumber * res,
decNumber * lhs, decNumber * rhs, const decNumber * lhs, const decNumber * rhs,
decContext * set, Flag op, uInt * status) decContext * set, Flag op, uInt * status)
{ {
decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */ decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */
...@@ -2709,12 +2711,13 @@ decDivideOp (decNumber * res, ...@@ -2709,12 +2711,13 @@ decDivideOp (decNumber * res,
Unit *var1 = varbuff; /* -> var1 array for long subtraction */ Unit *var1 = varbuff; /* -> var1 array for long subtraction */
Unit *varalloc = NULL; /* -> allocated buffer, iff used */ Unit *varalloc = NULL; /* -> allocated buffer, iff used */
Unit *var2; /* -> var2 array */ const Unit *var2; /* -> var2 array */
Int var1units, var2units; /* actual lengths */ Int var1units, var2units; /* actual lengths */
Int var2ulen; /* logical length (units) */ Int var2ulen; /* logical length (units) */
Int var1initpad = 0; /* var1 initial padding (digits) */ 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] */ Int msu2plus; /* msu2 plus one [does not vary] */
eInt msu2pair; /* msu2 pair plus one [does not vary] */ eInt msu2pair; /* msu2 pair plus one [does not vary] */
Int maxdigits; /* longest LHS or required acc length */ Int maxdigits; /* longest LHS or required acc length */
...@@ -2726,7 +2729,8 @@ decDivideOp (decNumber * res, ...@@ -2726,7 +2729,8 @@ decDivideOp (decNumber * res,
Int maxexponent = 0; /* DIVIDE maximum exponent if unrounded */ Int maxexponent = 0; /* DIVIDE maximum exponent if unrounded */
uByte bits; /* working sign */ uByte bits; /* working sign */
uByte merged; /* merged flags */ uByte merged; /* merged flags */
Unit *target, *source; /* work */ Unit *target; /* work */
const Unit *source; /* work */
uInt const *pow; /* .. */ uInt const *pow; /* .. */
Int shift, cut; /* .. */ Int shift, cut; /* .. */
#if DECSUBSET #if DECSUBSET
...@@ -3049,7 +3053,8 @@ decDivideOp (decNumber * res, ...@@ -3049,7 +3053,8 @@ decDivideOp (decNumber * res,
if (var1units == var2ulen) if (var1units == var2ulen)
{ /* unit-by-unit compare needed */ { /* unit-by-unit compare needed */
/* compare the two numbers, from msu */ /* 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 */ pv2 = msu2; /* -> msu */
for (pv1 = msu1;; pv1--, pv2--) for (pv1 = msu1;; pv1--, pv2--)
{ {
...@@ -3411,15 +3416,15 @@ decDivideOp (decNumber * res, ...@@ -3411,15 +3416,15 @@ decDivideOp (decNumber * res,
/* We always have to use a buffer for the accumulator. */ /* We always have to use a buffer for the accumulator. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static decNumber * static decNumber *
decMultiplyOp (decNumber * res, decNumber * lhs, decMultiplyOp (decNumber * res, const decNumber * lhs,
decNumber * rhs, decContext * set, uInt * status) const decNumber * rhs, decContext * set, uInt * status)
{ {
decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */ decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */
decNumber *allocrhs = NULL; /* .., rhs */ decNumber *allocrhs = NULL; /* .., rhs */
Unit accbuff[D2U (DECBUFFER * 2 + 1)]; /* local buffer (+1 in case DECBUFFER==0) */ Unit accbuff[D2U (DECBUFFER * 2 + 1)]; /* local buffer (+1 in case DECBUFFER==0) */
Unit *acc = accbuff; /* -> accumulator array for exact result */ Unit *acc = accbuff; /* -> accumulator array for exact result */
Unit *allocacc = NULL; /* -> allocated buffer, iff allocated */ Unit *allocacc = NULL; /* -> allocated buffer, iff allocated */
Unit *mer, *mermsup; /* work */ const Unit *mer, *mermsup; /* work */
Int accunits; /* Units of accumulator in use */ Int accunits; /* Units of accumulator in use */
Int madlength; /* Units in multiplicand */ Int madlength; /* Units in multiplicand */
Int shift; /* Units to shift multiplicand by */ Int shift; /* Units to shift multiplicand by */
...@@ -3486,7 +3491,7 @@ decMultiplyOp (decNumber * res, decNumber * lhs, ...@@ -3486,7 +3491,7 @@ decMultiplyOp (decNumber * res, decNumber * lhs,
/* multiplier (rhs) and the longer as the multiplicand (lhs) */ /* multiplier (rhs) and the longer as the multiplicand (lhs) */
if (lhs->digits < rhs->digits) if (lhs->digits < rhs->digits)
{ /* swap... */ { /* swap... */
decNumber *hold = lhs; const decNumber *hold = lhs;
lhs = rhs; lhs = rhs;
rhs = hold; rhs = hold;
} }
...@@ -3593,12 +3598,12 @@ decMultiplyOp (decNumber * res, decNumber * lhs, ...@@ -3593,12 +3598,12 @@ decMultiplyOp (decNumber * res, decNumber * lhs,
/* after the operation is guaranteed to be that requested. */ /* after the operation is guaranteed to be that requested. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static decNumber * static decNumber *
decQuantizeOp (decNumber * res, decNumber * lhs, decQuantizeOp (decNumber * res, const decNumber * lhs,
decNumber * rhs, decContext * set, Flag quant, uInt * status) const decNumber * rhs, decContext * set, Flag quant, uInt * status)
{ {
decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */ decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */
decNumber *allocrhs = NULL; /* .., rhs */ decNumber *allocrhs = NULL; /* .., rhs */
decNumber *inrhs = rhs; /* save original rhs */ const decNumber *inrhs = rhs; /* save original rhs */
Int reqdigits = set->digits; /* requested DIGITS */ Int reqdigits = set->digits; /* requested DIGITS */
Int reqexp; /* requested exponent [-scale] */ Int reqexp; /* requested exponent [-scale] */
Int residue = 0; /* rounding residue */ Int residue = 0; /* rounding residue */
...@@ -3776,7 +3781,7 @@ decQuantizeOp (decNumber * res, decNumber * lhs, ...@@ -3776,7 +3781,7 @@ decQuantizeOp (decNumber * res, decNumber * lhs,
/* coefficient comparison if possible. */ /* coefficient comparison if possible. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decCompareOp (decNumber * res, decNumber * lhs, decNumber * rhs, decCompareOp (decNumber * res, const decNumber * lhs, const decNumber * rhs,
decContext * set, Flag op, uInt * status) decContext * set, Flag op, uInt * status)
{ {
decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */ decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */
...@@ -3873,7 +3878,7 @@ decCompareOp (decNumber * res, decNumber * lhs, decNumber * rhs, ...@@ -3873,7 +3878,7 @@ decCompareOp (decNumber * res, decNumber * lhs, decNumber * rhs,
{ /* MAX or MIN, non-NaN result */ { /* MAX or MIN, non-NaN result */
Int residue = 0; /* rounding accumulator */ Int residue = 0; /* rounding accumulator */
/* choose the operand for the result */ /* choose the operand for the result */
decNumber *choice; const decNumber *choice;
if (result == 0) if (result == 0)
{ /* operands are numerically equal */ { /* operands are numerically equal */
/* choose according to sign then exponent (see 754r) */ /* choose according to sign then exponent (see 754r) */
...@@ -3940,7 +3945,7 @@ decCompareOp (decNumber * res, decNumber * lhs, decNumber * rhs, ...@@ -3940,7 +3945,7 @@ decCompareOp (decNumber * res, decNumber * lhs, decNumber * rhs,
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* This could be merged into decCompareOp */ /* This could be merged into decCompareOp */
static Int static Int
decCompare (decNumber * lhs, decNumber * rhs) decCompare (const decNumber * lhs, const decNumber * rhs)
{ {
Int result; /* result value */ Int result; /* result value */
Int sigr; /* rhs signum */ Int sigr; /* rhs signum */
...@@ -3977,7 +3982,7 @@ decCompare (decNumber * lhs, decNumber * rhs) ...@@ -3977,7 +3982,7 @@ decCompare (decNumber * lhs, decNumber * rhs)
if (lhs->exponent > rhs->exponent) if (lhs->exponent > rhs->exponent)
{ /* LHS exponent larger */ { /* LHS exponent larger */
/* swap sides, and sign */ /* swap sides, and sign */
decNumber *temp = lhs; const decNumber *temp = lhs;
lhs = rhs; lhs = rhs;
rhs = temp; rhs = temp;
result = -result; result = -result;
...@@ -4009,13 +4014,13 @@ decCompare (decNumber * lhs, decNumber * rhs) ...@@ -4009,13 +4014,13 @@ decCompare (decNumber * lhs, decNumber * rhs)
/* (the only possible failure is an allocation error) */ /* (the only possible failure is an allocation error) */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static Int 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 *acc; /* accumulator for result */
Unit accbuff[D2U (DECBUFFER + 1)]; /* local buffer */ Unit accbuff[D2U (DECBUFFER + 1)]; /* local buffer */
Unit *allocacc = NULL; /* -> allocated acc buffer, iff allocated */ Unit *allocacc = NULL; /* -> allocated acc buffer, iff allocated */
Int accunits, need; /* units in use or needed for acc */ 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; /* .. */ Int expunits, exprem, result; /* .. */
if (exp == 0) if (exp == 0)
...@@ -4129,10 +4134,10 @@ decUnitCompare (Unit * a, Int alength, Unit * b, Int blength, Int exp) ...@@ -4129,10 +4134,10 @@ decUnitCompare (Unit * a, Int alength, Unit * b, Int blength, Int exp)
/* (IBM Warwick, UK) for some of the ideas used in this routine. */ /* (IBM Warwick, UK) for some of the ideas used in this routine. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static Int static Int
decUnitAddSub (Unit * a, Int alength, decUnitAddSub (const Unit * a, Int alength,
Unit * b, Int blength, Int bshift, Unit * c, Int m) 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 *clsu = c; /* C ditto */
Unit *minC; /* low water mark for C */ Unit *minC; /* low water mark for C */
Unit *maxC; /* high water mark for C */ Unit *maxC; /* high water mark for C */
...@@ -4556,7 +4561,7 @@ decShiftToLeast (Unit * uar, Int units, Int shift) ...@@ -4556,7 +4561,7 @@ decShiftToLeast (Unit * uar, Int units, Int shift)
/* is returned. */ /* is returned. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static decNumber * static decNumber *
decRoundOperand (decNumber * dn, decContext * set, uInt * status) decRoundOperand (const decNumber * dn, decContext * set, uInt * status)
{ {
decNumber *res; /* result structure */ decNumber *res; /* result structure */
uInt newstatus = 0; /* status from round */ uInt newstatus = 0; /* status from round */
...@@ -4595,7 +4600,7 @@ decRoundOperand (decNumber * dn, decContext * set, uInt * status) ...@@ -4595,7 +4600,7 @@ decRoundOperand (decNumber * dn, decContext * set, uInt * status)
/* All fields are updated as required. */ /* All fields are updated as required. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static void static void
decCopyFit (decNumber * dest, decNumber * src, decContext * set, decCopyFit (decNumber * dest, const decNumber * src, decContext * set,
Int * residue, uInt * status) Int * residue, uInt * status)
{ {
dest->bits = src->bits; dest->bits = src->bits;
...@@ -4643,14 +4648,15 @@ decCopyFit (decNumber * dest, decNumber * src, decContext * set, ...@@ -4643,14 +4648,15 @@ decCopyFit (decNumber * dest, decNumber * src, decContext * set,
/* 0 1 2 3 4 5 6 7 8 9 */ /* 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 const uByte resmap[10] = { 0, 3, 3, 3, 3, 5, 7, 7, 7, 7 };
static void static void
decSetCoeff (decNumber * dn, decContext * set, Unit * lsu, decSetCoeff (decNumber * dn, decContext * set, const Unit * lsu,
Int len, Int * residue, uInt * status) Int len, Int * residue, uInt * status)
{ {
Int discard; /* number of digits to discard */ Int discard; /* number of digits to discard */
uInt discard1; /* first discarded digit */ uInt discard1; /* first discarded digit */
uInt cut; /* cut point in Unit */ uInt cut; /* cut point in Unit */
uInt quot, rem; /* for divisions */ uInt quot, rem; /* for divisions */
Unit *up, *target; /* work */ Unit *target; /* work */
const Unit *up; /* work */
Int count; /* .. */ Int count; /* .. */
#if DECDPUN<=4 #if DECDPUN<=4
uInt temp; /* .. */ uInt temp; /* .. */
...@@ -5246,8 +5252,8 @@ decSetOverflow (decNumber * dn, decContext * set, uInt * status) ...@@ -5246,8 +5252,8 @@ decSetOverflow (decNumber * dn, decContext * set, uInt * status)
/* necessary. Underflow is set if the result is Inexact. */ /* necessary. Underflow is set if the result is Inexact. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static void static void
decSetSubnormal (decNumber * dn, decContext * set, Int * residue, decSetSubnormal (decNumber * dn, decContext * set,
uInt * status) Int * residue, uInt * status)
{ {
decContext workset; /* work */ decContext workset; /* work */
Int etiny, adjust; /* .. */ Int etiny, adjust; /* .. */
...@@ -5342,15 +5348,15 @@ decSetSubnormal (decNumber * dn, decContext * set, Int * residue, ...@@ -5342,15 +5348,15 @@ decSetSubnormal (decNumber * dn, decContext * set, Int * residue,
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
#if DECSUBSET #if DECSUBSET
static Int static Int
decGetInt (decNumber * dn, decContext * set) decGetInt (const decNumber * dn, decContext * set)
{ {
#else #else
static Int static Int
decGetInt (decNumber * dn) decGetInt (const decNumber * dn)
{ {
#endif #endif
Int theInt; /* result accumulator */ Int theInt; /* result accumulator */
Unit *up; /* work */ const Unit *up; /* work */
Int got; /* digits (real or not) processed */ Int got; /* digits (real or not) processed */
Int ilength = dn->digits + dn->exponent; /* integral length */ Int ilength = dn->digits + dn->exponent; /* integral length */
...@@ -5472,7 +5478,7 @@ decStrEq (const char *str1, const char *str2) ...@@ -5472,7 +5478,7 @@ decStrEq (const char *str1, const char *str2)
/* to a qNaN and Invalid operation is set. */ /* to a qNaN and Invalid operation is set. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static decNumber * 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, */ /* This decision tree ends up with LHS being the source pointer, */
/* and status updated if need be */ /* and status updated if need be */
...@@ -5543,9 +5549,9 @@ decStatus (decNumber * dn, uInt status, decContext * set) ...@@ -5543,9 +5549,9 @@ decStatus (decNumber * dn, uInt status, decContext * set)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* This may be called twice during some operations. */ /* This may be called twice during some operations. */
static Int 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 */ Int digits = len * DECDPUN; /* maximum possible digits */
uInt const *pow; /* work */ uInt const *pow; /* work */
...@@ -5584,9 +5590,9 @@ decGetDigits (Unit * uar, Int len) ...@@ -5584,9 +5590,9 @@ decGetDigits (Unit * uar, Int len)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* this is public so other modules can use it */ /* this is public so other modules can use it */
void void
decNumberShow (decNumber * dn) decNumberShow (const decNumber * dn)
{ {
Unit *up; /* work */ const Unit *up; /* work */
uInt u, d; /* .. */ uInt u, d; /* .. */
Int cut; /* .. */ Int cut; /* .. */
char isign = '+'; /* main sign */ char isign = '+'; /* main sign */
...@@ -5652,13 +5658,13 @@ decNumberShow (decNumber * dn) ...@@ -5652,13 +5658,13 @@ decNumberShow (decNumber * dn)
/* len is the length of the array in Units */ /* len is the length of the array in Units */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static void static void
decDumpAr (char name, Unit * ar, Int len) decDumpAr (char name, const Unit * ar, Int len)
{ {
Int i; Int i;
#if DECDPUN==4 #if DECDPUN==4
char *spec = "%04d "; const char *spec = "%04d ";
#else #else
char *spec = "%d "; const char *spec = "%d ";
#endif #endif
printf (" :%c: ", name); printf (" :%c: ", name);
for (i = len - 1; i >= 0; i--) for (i = len - 1; i >= 0; i--)
...@@ -5688,8 +5694,8 @@ decDumpAr (char name, Unit * ar, Int len) ...@@ -5688,8 +5694,8 @@ decDumpAr (char name, Unit * ar, Int len)
/* The caller is expected to abandon immediately if 1 is returned. */ /* The caller is expected to abandon immediately if 1 is returned. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static Flag static Flag
decCheckOperands (decNumber * res, decNumber * lhs, decCheckOperands (decNumber * res, const decNumber * lhs,
decNumber * rhs, decContext * set) const decNumber * rhs, decContext * set)
{ {
Flag bad = 0; Flag bad = 0;
if (set == NULL) if (set == NULL)
...@@ -5746,9 +5752,9 @@ decCheckOperands (decNumber * res, decNumber * lhs, ...@@ -5746,9 +5752,9 @@ decCheckOperands (decNumber * res, decNumber * lhs,
/* operation in some valid context (not necessarily the current one). */ /* operation in some valid context (not necessarily the current one). */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
Flag Flag
decCheckNumber (decNumber * dn, decContext * set) decCheckNumber (const decNumber * dn, decContext * set)
{ {
Unit *up; /* work */ const Unit *up; /* work */
uInt maxuint; /* .. */ uInt maxuint; /* .. */
Int ae, d, digits; /* .. */ Int ae, d, digits; /* .. */
Int emin, emax; /* .. */ Int emin, emax; /* .. */
......
...@@ -130,43 +130,46 @@ typedef struct ...@@ -130,43 +130,46 @@ typedef struct
/* Conversions */ /* Conversions */
decNumber *decNumberFromString (decNumber *, const char *, decContext *); decNumber *decNumberFromString (decNumber *, const char *, decContext *);
char *decNumberToString (decNumber *, char *); char *decNumberToString (const decNumber *, char *);
char *decNumberToEngString (decNumber *, char *); char *decNumberToEngString (const decNumber *, char *);
/* Operators */ /* Operators */
decNumber *decNumberAbs (decNumber *, decNumber *, decContext *); decNumber *decNumberAbs (decNumber *, const decNumber *, decContext *);
decNumber *decNumberAdd (decNumber *, decNumber *, decNumber *, decContext *); decNumber *decNumberAdd (decNumber *, const decNumber *,
decNumber *decNumberCompare (decNumber *, decNumber *, decNumber *, const decNumber *, decContext *);
decContext *); decNumber *decNumberCompare (decNumber *, const decNumber *,
decNumber *decNumberDivide (decNumber *, decNumber *, decNumber *, const decNumber *, decContext *);
decContext *); decNumber *decNumberDivide (decNumber *, const decNumber *,
decNumber *decNumberDivideInteger (decNumber *, decNumber *, decNumber *, const decNumber *, decContext *);
decContext *); decNumber *decNumberDivideInteger (decNumber *, const decNumber *,
decNumber *decNumberMax (decNumber *, decNumber *, decNumber *, decContext *); const decNumber *, decContext *);
decNumber *decNumberMin (decNumber *, decNumber *, decNumber *, decContext *); decNumber *decNumberMax (decNumber *, const decNumber *,
decNumber *decNumberMinus (decNumber *, decNumber *, decContext *); const decNumber *, decContext *);
decNumber *decNumberMultiply (decNumber *, decNumber *, decNumber *, decNumber *decNumberMin (decNumber *, const decNumber *,
decContext *); const decNumber *, decContext *);
decNumber *decNumberNormalize (decNumber *, decNumber *, decContext *); decNumber *decNumberMinus (decNumber *, const decNumber *, decContext *);
decNumber *decNumberPlus (decNumber *, decNumber *, decContext *); 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 *, decNumber *decNumberPower (decNumber *, decNumber *, decNumber *,
decContext *); decContext *);
decNumber *decNumberQuantize (decNumber *, decNumber *, decNumber *, decNumber *decNumberQuantize (decNumber *, const decNumber *,
decContext *); const decNumber *, decContext *);
decNumber *decNumberRemainder (decNumber *, decNumber *, decNumber *, decNumber *decNumberRemainder (decNumber *, const decNumber *,
decContext *); const decNumber *, decContext *);
decNumber *decNumberRemainderNear (decNumber *, decNumber *, decNumber *, decNumber *decNumberRemainderNear (decNumber *, const decNumber *,
decContext *); const decNumber *, decContext *);
decNumber *decNumberRescale (decNumber *, decNumber *, decNumber *, decNumber *decNumberRescale (decNumber *, const decNumber *,
decContext *); const decNumber *, decContext *);
decNumber *decNumberSameQuantum (decNumber *, decNumber *, decNumber *); decNumber *decNumberSameQuantum (decNumber *, const decNumber *, const decNumber *);
decNumber *decNumberSquareRoot (decNumber *, decNumber *, decContext *); decNumber *decNumberSquareRoot (decNumber *, const decNumber *, decContext *);
decNumber *decNumberSubtract (decNumber *, decNumber *, decNumber *, decNumber *decNumberSubtract (decNumber *, const decNumber *,
decContext *); const decNumber *, decContext *);
decNumber *decNumberToIntegralValue (decNumber *, decNumber *, decContext *); decNumber *decNumberToIntegralValue (decNumber *, const decNumber *, decContext *);
/* Utilities */ /* Utilities */
decNumber *decNumberCopy (decNumber *, decNumber *); decNumber *decNumberCopy (decNumber *, const decNumber *);
decNumber *decNumberTrim (decNumber *); decNumber *decNumberTrim (decNumber *);
const char *decNumberVersion (void); const char *decNumberVersion (void);
decNumber *decNumberZero (decNumber *); decNumber *decNumberZero (decNumber *);
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
/* No error is possible. */ /* No error is possible. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
void void
decDensePackCoeff (decNumber * dn, uByte * bytes, Int len, Int shift) decDensePackCoeff (const decNumber * dn, uByte * bytes, Int len, Int shift)
{ {
Int cut; /* work */ Int cut; /* work */
Int n; /* output bunch counter */ Int n; /* output bunch counter */
...@@ -72,7 +72,7 @@ decDensePackCoeff (decNumber * dn, uByte * bytes, Int len, Int shift) ...@@ -72,7 +72,7 @@ decDensePackCoeff (decNumber * dn, uByte * bytes, Int len, Int shift)
uInt dpd; /* densely packed decimal value */ uInt dpd; /* densely packed decimal value */
uInt bin; /* binary value 0-999 */ uInt bin; /* binary value 0-999 */
uByte *bout; /* -> current output byte */ uByte *bout; /* -> current output byte */
Unit *inu = dn->lsu; /* -> current input unit */ const Unit *inu = dn->lsu; /* -> current input unit */
Unit uar[DECMAXUNITS]; /* working copy of units, iff shifted */ Unit uar[DECMAXUNITS]; /* working copy of units, iff shifted */
#if DECDPUN!=3 /* not fast path */ #if DECDPUN!=3 /* not fast path */
Unit in; /* current input unit */ Unit in; /* current input unit */
...@@ -83,7 +83,8 @@ decDensePackCoeff (decNumber * dn, uByte * bytes, Int len, Int shift) ...@@ -83,7 +83,8 @@ decDensePackCoeff (decNumber * dn, uByte * bytes, Int len, Int shift)
/* shift the units array to the left by pad digits and copy */ /* shift the units array to the left by pad digits and copy */
/* [this code is a special case of decShiftToMost, which could */ /* [this code is a special case of decShiftToMost, which could */
/* be used instead if exposed and the array were copied first] */ /* be used instead if exposed and the array were copied first] */
Unit *target, *source, *first; /* work */ Unit *target, *first; /* work */
const Unit *source; /* work */
uInt next = 0; /* work */ uInt next = 0; /* work */
source = dn->lsu + D2U (digits) - 1; /* where msu comes from */ source = dn->lsu + D2U (digits) - 1; /* where msu comes from */
...@@ -211,12 +212,12 @@ decDensePackCoeff (decNumber * dn, uByte * bytes, Int len, Int shift) ...@@ -211,12 +212,12 @@ decDensePackCoeff (decNumber * dn, uByte * bytes, Int len, Int shift)
/* No error is possible [the redundant 888 codes are allowed]. */ /* No error is possible [the redundant 888 codes are allowed]. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
void void
decDenseUnpackCoeff (uByte * bytes, Int len, decNumber * dn, decDenseUnpackCoeff (const uByte * bytes, Int len, decNumber * dn,
Int bunches, Int odd) Int bunches, Int odd)
{ {
uInt dpd = 0; /* collector for 10 bits */ uInt dpd = 0; /* collector for 10 bits */
Int n; /* counter */ Int n; /* counter */
uByte *bin; /* -> current input byte */ const uByte *bin; /* -> current input byte */
Unit *uout = dn->lsu; /* -> current output unit */ Unit *uout = dn->lsu; /* -> current output unit */
Unit out = 0; /* accumulator */ Unit out = 0; /* accumulator */
Int cut = 0; /* power of ten in current unit */ Int cut = 0; /* power of ten in current unit */
......
...@@ -24,5 +24,5 @@ ...@@ -24,5 +24,5 @@
#define decDenseUnpackCoeff __decDenseUnpackCoeff #define decDenseUnpackCoeff __decDenseUnpackCoeff
#endif #endif
extern void decDensePackCoeff (decNumber *, uByte *, Int, Int); extern void decDensePackCoeff (const decNumber *, uByte *, Int, Int);
extern void decDenseUnpackCoeff (uByte *, Int, decNumber *, Int, Int); extern void decDenseUnpackCoeff (const uByte *, Int, decNumber *, Int, Int);
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
#include "decUtility.h" /* utility routines */ #include "decUtility.h" /* utility routines */
#if DECTRACE || DECCHECK #if DECTRACE || DECCHECK
void decimal128Show (decimal128 *); /* for debug */ void decimal128Show (const decimal128 *); /* for debug */
void decNumberShow (decNumber *); /* .. */ void decNumberShow (const decNumber *); /* .. */
#endif #endif
/* Useful macro */ /* Useful macro */
...@@ -64,7 +64,7 @@ void decNumberShow (decNumber *); /* .. */ ...@@ -64,7 +64,7 @@ void decNumberShow (decNumber *); /* .. */
/* power of ten, or if the exponent on a zero had to be clamped. */ /* power of ten, or if the exponent on a zero had to be clamped. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decimal128 * decimal128 *
decimal128FromNumber (decimal128 * d128, decNumber * dn, decContext * set) decimal128FromNumber (decimal128 * d128, const decNumber * dn, decContext * set)
{ {
uInt status = 0; /* status accumulator */ uInt status = 0; /* status accumulator */
Int pad = 0; /* coefficient pad digits */ Int pad = 0; /* coefficient pad digits */
...@@ -184,7 +184,7 @@ decimal128FromNumber (decimal128 * d128, decNumber * dn, decContext * set) ...@@ -184,7 +184,7 @@ decimal128FromNumber (decimal128 * d128, decNumber * dn, decContext * set)
/* No error is possible. */ /* No error is possible. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decimal128ToNumber (decimal128 * d128, decNumber * dn) decimal128ToNumber (const decimal128 * d128, decNumber * dn)
{ {
uInt msd; /* coefficient MSD */ uInt msd; /* coefficient MSD */
decimal128 wk; /* working copy, if needed */ decimal128 wk; /* working copy, if needed */
...@@ -263,7 +263,7 @@ decimal128ToNumber (decimal128 * d128, decNumber * dn) ...@@ -263,7 +263,7 @@ decimal128ToNumber (decimal128 * d128, decNumber * dn)
/* No error is possible, and no status can be set. */ /* No error is possible, and no status can be set. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
char * char *
decimal128ToString (decimal128 * d128, char *string) decimal128ToString (const decimal128 * d128, char *string)
{ {
decNumber dn; /* work */ decNumber dn; /* work */
decimal128ToNumber (d128, &dn); decimal128ToNumber (d128, &dn);
...@@ -272,7 +272,7 @@ decimal128ToString (decimal128 * d128, char *string) ...@@ -272,7 +272,7 @@ decimal128ToString (decimal128 * d128, char *string)
} }
char * char *
decimal128ToEngString (decimal128 * d128, char *string) decimal128ToEngString (const decimal128 * d128, char *string)
{ {
decNumber dn; /* work */ decNumber dn; /* work */
decimal128ToNumber (d128, &dn); decimal128ToNumber (d128, &dn);
...@@ -321,7 +321,7 @@ decimal128FromString (decimal128 * result, const char *string, decContext * set) ...@@ -321,7 +321,7 @@ decimal128FromString (decimal128 * result, const char *string, decContext * set)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* Also shows sign/cob/expconfields extracted */ /* Also shows sign/cob/expconfields extracted */
void void
decimal128Show (decimal128 * d128) decimal128Show (const decimal128 * d128)
{ {
char buf[DECIMAL128_Bytes * 2 + 1]; char buf[DECIMAL128_Bytes * 2 + 1];
Int i, j; Int i, j;
......
...@@ -103,11 +103,11 @@ typedef struct ...@@ -103,11 +103,11 @@ typedef struct
/* String conversions */ /* String conversions */
decimal128 *decimal128FromString (decimal128 *, const char *, decContext *); decimal128 *decimal128FromString (decimal128 *, const char *, decContext *);
char *decimal128ToString (decimal128 *, char *); char *decimal128ToString (const decimal128 *, char *);
char *decimal128ToEngString (decimal128 *, char *); char *decimal128ToEngString (const decimal128 *, char *);
/* decNumber conversions */ /* decNumber conversions */
decimal128 *decimal128FromNumber (decimal128 *, decNumber *, decContext *); decimal128 *decimal128FromNumber (decimal128 *, const decNumber *, decContext *);
decNumber *decimal128ToNumber (decimal128 *, decNumber *); decNumber *decimal128ToNumber (const decimal128 *, decNumber *);
#endif #endif
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
#include "decUtility.h" /* utility routines */ #include "decUtility.h" /* utility routines */
#if DECTRACE || DECCHECK #if DECTRACE || DECCHECK
void decimal32Show (decimal32 *); /* for debug */ void decimal32Show (const decimal32 *); /* for debug */
void decNumberShow (decNumber *); /* .. */ void decNumberShow (const decNumber *); /* .. */
#endif #endif
/* Useful macro */ /* Useful macro */
...@@ -64,7 +64,7 @@ void decNumberShow (decNumber *); /* .. */ ...@@ -64,7 +64,7 @@ void decNumberShow (decNumber *); /* .. */
/* power of ten, or if the exponent on a zero had to be clamped. */ /* power of ten, or if the exponent on a zero had to be clamped. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decimal32 * decimal32 *
decimal32FromNumber (decimal32 * d32, decNumber * dn, decContext * set) decimal32FromNumber (decimal32 * d32, const decNumber * dn, decContext * set)
{ {
uInt status = 0; /* status accumulator */ uInt status = 0; /* status accumulator */
Int pad = 0; /* coefficient pad digits */ Int pad = 0; /* coefficient pad digits */
...@@ -181,7 +181,7 @@ decimal32FromNumber (decimal32 * d32, decNumber * dn, decContext * set) ...@@ -181,7 +181,7 @@ decimal32FromNumber (decimal32 * d32, decNumber * dn, decContext * set)
/* No error is possible. */ /* No error is possible. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decimal32ToNumber (decimal32 * d32, decNumber * dn) decimal32ToNumber (const decimal32 * d32, decNumber * dn)
{ {
uInt msd; /* coefficient MSD */ uInt msd; /* coefficient MSD */
decimal32 wk; /* working copy, if needed */ decimal32 wk; /* working copy, if needed */
...@@ -255,7 +255,7 @@ decimal32ToNumber (decimal32 * d32, decNumber * dn) ...@@ -255,7 +255,7 @@ decimal32ToNumber (decimal32 * d32, decNumber * dn)
/* No error is possible, and no status can be set. */ /* No error is possible, and no status can be set. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
char * char *
decimal32ToString (decimal32 * d32, char *string) decimal32ToString (const decimal32 * d32, char *string)
{ {
decNumber dn; /* work */ decNumber dn; /* work */
decimal32ToNumber (d32, &dn); decimal32ToNumber (d32, &dn);
...@@ -264,7 +264,7 @@ decimal32ToString (decimal32 * d32, char *string) ...@@ -264,7 +264,7 @@ decimal32ToString (decimal32 * d32, char *string)
} }
char * char *
decimal32ToEngString (decimal32 * d32, char *string) decimal32ToEngString (const decimal32 * d32, char *string)
{ {
decNumber dn; /* work */ decNumber dn; /* work */
decimal32ToNumber (d32, &dn); decimal32ToNumber (d32, &dn);
...@@ -312,7 +312,7 @@ decimal32FromString (decimal32 * result, const char *string, decContext * set) ...@@ -312,7 +312,7 @@ decimal32FromString (decimal32 * result, const char *string, decContext * set)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* Also shows sign/cob/expconfields extracted */ /* Also shows sign/cob/expconfields extracted */
void void
decimal32Show (decimal32 * d32) decimal32Show (const decimal32 * d32)
{ {
char buf[DECIMAL32_Bytes * 2 + 1]; char buf[DECIMAL32_Bytes * 2 + 1];
Int i, j; Int i, j;
......
...@@ -93,11 +93,11 @@ typedef struct ...@@ -93,11 +93,11 @@ typedef struct
/* String conversions. */ /* String conversions. */
decimal32 *decimal32FromString (decimal32 *, const char *, decContext *); decimal32 *decimal32FromString (decimal32 *, const char *, decContext *);
char *decimal32ToString (decimal32 *, char *); char *decimal32ToString (const decimal32 *, char *);
char *decimal32ToEngString (decimal32 *, char *); char *decimal32ToEngString (const decimal32 *, char *);
/* decNumber conversions. */ /* decNumber conversions. */
decimal32 *decimal32FromNumber (decimal32 *, decNumber *, decContext *); decimal32 *decimal32FromNumber (decimal32 *, const decNumber *, decContext *);
decNumber *decimal32ToNumber (decimal32 *, decNumber *); decNumber *decimal32ToNumber (const decimal32 *, decNumber *);
#endif #endif
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
#include "decUtility.h" /* utility routines */ #include "decUtility.h" /* utility routines */
#if DECTRACE || DECCHECK #if DECTRACE || DECCHECK
void decimal64Show (decimal64 *); /* for debug */ void decimal64Show (const decimal64 *); /* for debug */
void decNumberShow (decNumber *); /* .. */ void decNumberShow (const decNumber *); /* .. */
#endif #endif
/* Useful macro */ /* Useful macro */
...@@ -64,7 +64,7 @@ void decNumberShow (decNumber *); /* .. */ ...@@ -64,7 +64,7 @@ void decNumberShow (decNumber *); /* .. */
/* power of ten, or if the exponent on a zero had to be clamped. */ /* power of ten, or if the exponent on a zero had to be clamped. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decimal64 * decimal64 *
decimal64FromNumber (decimal64 * d64, decNumber * dn, decContext * set) decimal64FromNumber (decimal64 * d64, const decNumber * dn, decContext * set)
{ {
uInt status = 0; /* status accumulator */ uInt status = 0; /* status accumulator */
Int pad = 0; /* coefficient pad digits */ Int pad = 0; /* coefficient pad digits */
...@@ -180,7 +180,7 @@ decimal64FromNumber (decimal64 * d64, decNumber * dn, decContext * set) ...@@ -180,7 +180,7 @@ decimal64FromNumber (decimal64 * d64, decNumber * dn, decContext * set)
/* No error is possible. */ /* No error is possible. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decNumber *
decimal64ToNumber (decimal64 * d64, decNumber * dn) decimal64ToNumber (const decimal64 * d64, decNumber * dn)
{ {
uInt msd; /* coefficient MSD */ uInt msd; /* coefficient MSD */
decimal64 wk; /* working copy, if needed */ decimal64 wk; /* working copy, if needed */
...@@ -254,7 +254,7 @@ decimal64ToNumber (decimal64 * d64, decNumber * dn) ...@@ -254,7 +254,7 @@ decimal64ToNumber (decimal64 * d64, decNumber * dn)
/* No error is possible, and no status can be set. */ /* No error is possible, and no status can be set. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
char * char *
decimal64ToString (decimal64 * d64, char *string) decimal64ToString (const decimal64 * d64, char *string)
{ {
decNumber dn; /* work */ decNumber dn; /* work */
decimal64ToNumber (d64, &dn); decimal64ToNumber (d64, &dn);
...@@ -263,7 +263,7 @@ decimal64ToString (decimal64 * d64, char *string) ...@@ -263,7 +263,7 @@ decimal64ToString (decimal64 * d64, char *string)
} }
char * char *
decimal64ToEngString (decimal64 * d64, char *string) decimal64ToEngString (const decimal64 * d64, char *string)
{ {
decNumber dn; /* work */ decNumber dn; /* work */
decimal64ToNumber (d64, &dn); decimal64ToNumber (d64, &dn);
...@@ -312,7 +312,7 @@ decimal64FromString (decimal64 * result, const char *string, decContext * set) ...@@ -312,7 +312,7 @@ decimal64FromString (decimal64 * result, const char *string, decContext * set)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* Also shows sign/cob/expconfields extracted */ /* Also shows sign/cob/expconfields extracted */
void void
decimal64Show (decimal64 * d64) decimal64Show (const decimal64 * d64)
{ {
char buf[DECIMAL64_Bytes * 2 + 1]; char buf[DECIMAL64_Bytes * 2 + 1];
Int i, j; Int i, j;
......
...@@ -97,11 +97,11 @@ typedef struct ...@@ -97,11 +97,11 @@ typedef struct
/* String conversions */ /* String conversions */
decimal64 *decimal64FromString (decimal64 *, const char *, decContext *); decimal64 *decimal64FromString (decimal64 *, const char *, decContext *);
char *decimal64ToString (decimal64 *, char *); char *decimal64ToString (const decimal64 *, char *);
char *decimal64ToEngString (decimal64 *, char *); char *decimal64ToEngString (const decimal64 *, char *);
/* decNumber conversions */ /* decNumber conversions */
decimal64 *decimal64FromNumber (decimal64 *, decNumber *, decContext *); decimal64 *decimal64FromNumber (decimal64 *, const decNumber *, decContext *);
decNumber *decimal64ToNumber (decimal64 *, decNumber *); decNumber *decimal64ToNumber (const decimal64 *, decNumber *);
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment