Commit f988ec96 by Ben Elliston Committed by Ben Elliston

decNumber.c, [...]: Upgrade to decNumber 3.61.

	* decNumber.c, decNumber.h, decNumberLocal.h, decDouble.c,
	decDouble.h, decSingle.c, decContext.c, decSingle.h, decPacked.c,
	decCommon.c, decContext.h, decQuad.c, decPacked.h, decQuad.h,
	decDPD.h, decBasic.c: Upgrade to decNumber 3.61.
	* dpd/decimal128.h, dpd/decimal32.c, dpd/decimal32.h,
	dpd/decimal64.c, dpd/decimal128.c, dpd/decimal64.h: Likewise.

From-SVN: r145222
parent 7cdc1972
2009-03-29 Ben Elliston <bje@au.ibm.com>
* decNumber.c, decNumber.h, decNumberLocal.h, decDouble.c,
decDouble.h, decSingle.c, decContext.c, decSingle.h, decPacked.c,
decCommon.c, decContext.h, decQuad.c, decPacked.h, decQuad.h,
decDPD.h, decBasic.c: Upgrade to decNumber 3.61.
* dpd/decimal128.h, dpd/decimal32.c, dpd/decimal32.h,
dpd/decimal64.c, dpd/decimal128.c, dpd/decimal64.h: Likewise.
2009-02-10 Joseph Myers <joseph@codesourcery.com> 2009-02-10 Joseph Myers <joseph@codesourcery.com>
* Makefile.in (clean): Don't remove makedepend$(EXEEXT). * Makefile.in (clean): Don't remove makedepend$(EXEEXT).
......
...@@ -38,15 +38,13 @@ ...@@ -38,15 +38,13 @@
#include <string.h> /* for strcmp */ #include <string.h> /* for strcmp */
#include <stdio.h> /* for printf if DECCHECK */ #include <stdio.h> /* for printf if DECCHECK */
#include "dconfig.h" /* for GCC definitions */ #include "dconfig.h" /* for GCC definitions */
#include "decContext.h" /* context and base types */ #include "decContext.h" /* context and base types */
#include "decNumberLocal.h" /* decNumber local types, etc. */ #include "decNumberLocal.h" /* decNumber local types, etc. */
#if DECCHECK
/* compile-time endian tester [assumes sizeof(Int)>1] */ /* compile-time endian tester [assumes sizeof(Int)>1] */
static const Int mfcone=1; /* constant 1 */ static const Int mfcone=1; /* constant 1 */
static const Flag *mfctop=(Flag *)&mfcone; /* -> top byte */ static const Flag *mfctop=(const Flag *)&mfcone; /* -> top byte */
#define LITEND *mfctop /* named flag; 1=little-endian */ #define LITEND *mfctop /* named flag; 1=little-endian */
#endif
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* round-for-reround digits */ /* round-for-reround digits */
...@@ -64,7 +62,7 @@ const uInt DECPOWERS[10]={1, 10, 100, 1000, 10000, 100000, 1000000, ...@@ -64,7 +62,7 @@ const uInt DECPOWERS[10]={1, 10, 100, 1000, 10000, 100000, 1000000,
/* */ /* */
/* context is the context structure to be queried */ /* context is the context structure to be queried */
/* mask indicates the bits to be cleared (the status bit that */ /* mask indicates the bits to be cleared (the status bit that */
/* corresponds to each 1 bit in the mask is cleared) */ /* corresponds to each 1 bit in the mask is cleared) */
/* returns context */ /* returns context */
/* */ /* */
/* No error is possible. */ /* No error is possible. */
...@@ -80,9 +78,9 @@ decContext *decContextClearStatus(decContext *context, uInt mask) { ...@@ -80,9 +78,9 @@ decContext *decContextClearStatus(decContext *context, uInt mask) {
/* context is the structure to be initialized */ /* context is the structure to be initialized */
/* kind selects the required set of default values, one of: */ /* kind selects the required set of default values, one of: */
/* DEC_INIT_BASE -- select ANSI X3-274 defaults */ /* DEC_INIT_BASE -- select ANSI X3-274 defaults */
/* DEC_INIT_DECIMAL32 -- select IEEE 754r defaults, 32-bit */ /* DEC_INIT_DECIMAL32 -- select IEEE 754 defaults, 32-bit */
/* DEC_INIT_DECIMAL64 -- select IEEE 754r defaults, 64-bit */ /* DEC_INIT_DECIMAL64 -- select IEEE 754 defaults, 64-bit */
/* DEC_INIT_DECIMAL128 -- select IEEE 754r defaults, 128-bit */ /* DEC_INIT_DECIMAL128 -- select IEEE 754 defaults, 128-bit */
/* For any other value a valid context is returned, but with */ /* For any other value a valid context is returned, but with */
/* Invalid_operation set in the status field. */ /* Invalid_operation set in the status field. */
/* returns a context structure with the appropriate initial values. */ /* returns a context structure with the appropriate initial values. */
...@@ -105,11 +103,11 @@ decContext * decContextDefault(decContext *context, Int kind) { ...@@ -105,11 +103,11 @@ decContext * decContextDefault(decContext *context, Int kind) {
break; break;
case DEC_INIT_DECIMAL32: case DEC_INIT_DECIMAL32:
context->digits=7; /* digits */ context->digits=7; /* digits */
context->emax=96; /* Emax */ context->emax=96; /* Emax */
context->emin=-95; /* Emin */ context->emin=-95; /* Emin */
context->round=DEC_ROUND_HALF_EVEN; /* 0.5 to nearest even */ context->round=DEC_ROUND_HALF_EVEN; /* 0.5 to nearest even */
context->traps=0; /* no traps set */ context->traps=0; /* no traps set */
context->clamp=1; /* clamp exponents */ context->clamp=1; /* clamp exponents */
#if DECSUBSET #if DECSUBSET
context->extended=1; /* set */ context->extended=1; /* set */
#endif #endif
...@@ -119,8 +117,8 @@ decContext * decContextDefault(decContext *context, Int kind) { ...@@ -119,8 +117,8 @@ decContext * decContextDefault(decContext *context, Int kind) {
context->emax=384; /* Emax */ context->emax=384; /* Emax */
context->emin=-383; /* Emin */ context->emin=-383; /* Emin */
context->round=DEC_ROUND_HALF_EVEN; /* 0.5 to nearest even */ context->round=DEC_ROUND_HALF_EVEN; /* 0.5 to nearest even */
context->traps=0; /* no traps set */ context->traps=0; /* no traps set */
context->clamp=1; /* clamp exponents */ context->clamp=1; /* clamp exponents */
#if DECSUBSET #if DECSUBSET
context->extended=1; /* set */ context->extended=1; /* set */
#endif #endif
...@@ -130,8 +128,8 @@ decContext * decContextDefault(decContext *context, Int kind) { ...@@ -130,8 +128,8 @@ decContext * decContextDefault(decContext *context, Int kind) {
context->emax=6144; /* Emax */ context->emax=6144; /* Emax */
context->emin=-6143; /* Emin */ context->emin=-6143; /* Emin */
context->round=DEC_ROUND_HALF_EVEN; /* 0.5 to nearest even */ context->round=DEC_ROUND_HALF_EVEN; /* 0.5 to nearest even */
context->traps=0; /* no traps set */ context->traps=0; /* no traps set */
context->clamp=1; /* clamp exponents */ context->clamp=1; /* clamp exponents */
#if DECSUBSET #if DECSUBSET
context->extended=1; /* set */ context->extended=1; /* set */
#endif #endif
...@@ -142,15 +140,6 @@ decContext * decContextDefault(decContext *context, Int kind) { ...@@ -142,15 +140,6 @@ decContext * decContextDefault(decContext *context, Int kind) {
decContextSetStatus(context, DEC_Invalid_operation); /* trap */ decContextSetStatus(context, DEC_Invalid_operation); /* trap */
} }
#if DECCHECK
if (LITEND!=DECLITEND) {
const char *adj;
if (LITEND) adj="little";
else adj="big";
printf("Warning: DECLITEND is set to %d, but this computer appears to be %s-endian\n",
DECLITEND, adj);
}
#endif
return context;} /* decContextDefault */ return context;} /* decContextDefault */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
...@@ -166,7 +155,7 @@ enum rounding decContextGetRounding(decContext *context) { ...@@ -166,7 +155,7 @@ enum rounding decContextGetRounding(decContext *context) {
} /* decContextGetRounding */ } /* decContextGetRounding */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* decContextGetStatus -- return current status */ /* decContextGetStatus -- return current status */
/* */ /* */
/* context is the context structure to be queried */ /* context is the context structure to be queried */
/* returns status */ /* returns status */
...@@ -181,8 +170,8 @@ uInt decContextGetStatus(decContext *context) { ...@@ -181,8 +170,8 @@ uInt decContextGetStatus(decContext *context) {
/* decContextRestoreStatus -- restore bits in current status */ /* decContextRestoreStatus -- restore bits in current status */
/* */ /* */
/* context is the context structure to be updated */ /* context is the context structure to be updated */
/* newstatus is the source for the bits to be restored */ /* newstatus is the source for the bits to be restored */
/* mask indicates the bits to be restored (the status bit that */ /* mask indicates the bits to be restored (the status bit that */
/* corresponds to each 1 bit in the mask is set to the value of */ /* corresponds to each 1 bit in the mask is set to the value of */
/* the correspnding bit in newstatus) */ /* the correspnding bit in newstatus) */
/* returns context */ /* returns context */
...@@ -252,7 +241,7 @@ decContext * decContextSetStatus(decContext *context, uInt status) { ...@@ -252,7 +241,7 @@ decContext * decContextSetStatus(decContext *context, uInt status) {
/* */ /* */
/* returns the context structure, unless the string is equal to */ /* returns the context structure, unless the string is equal to */
/* DEC_Condition_MU or is not recognized. In these cases NULL is */ /* DEC_Condition_MU or is not recognized. In these cases NULL is */
/* returned. */ /* returned. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decContext * decContextSetStatusFromString(decContext *context, decContext * decContextSetStatusFromString(decContext *context,
const char *string) { const char *string) {
...@@ -303,7 +292,7 @@ decContext * decContextSetStatusFromString(decContext *context, ...@@ -303,7 +292,7 @@ decContext * decContextSetStatusFromString(decContext *context,
/* */ /* */
/* returns the context structure, unless the string is equal to */ /* returns the context structure, unless the string is equal to */
/* DEC_Condition_MU or is not recognized. In these cases NULL is */ /* DEC_Condition_MU or is not recognized. In these cases NULL is */
/* returned. */ /* returned. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decContext * decContextSetStatusFromStringQuiet(decContext *context, decContext * decContextSetStatusFromStringQuiet(decContext *context,
const char *string) { const char *string) {
...@@ -356,11 +345,11 @@ decContext * decContextSetStatusQuiet(decContext *context, uInt status) { ...@@ -356,11 +345,11 @@ decContext * decContextSetStatusQuiet(decContext *context, uInt status) {
return context;} /* decContextSetStatusQuiet */ return context;} /* decContextSetStatusQuiet */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* decContextStatusToString -- convert status flags to a string */ /* decContextStatusToString -- convert status flags to a string */
/* */ /* */
/* context is a context with valid status field */ /* context is a context with valid status field */
/* */ /* */
/* returns a constant string describing the condition. If multiple */ /* returns a constant string describing the condition. If multiple */
/* (or no) flags are set, a generic constant message is returned. */ /* (or no) flags are set, a generic constant message is returned. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
const char *decContextStatusToString(const decContext *context) { const char *decContextStatusToString(const decContext *context) {
...@@ -385,11 +374,41 @@ const char *decContextStatusToString(const decContext *context) { ...@@ -385,11 +374,41 @@ const char *decContextStatusToString(const decContext *context) {
#if DECSUBSET #if DECSUBSET
if (status==DEC_Lost_digits ) return DEC_Condition_LD; if (status==DEC_Lost_digits ) return DEC_Condition_LD;
#endif #endif
if (status==0 ) return DEC_Condition_ZE; if (status==0 ) return DEC_Condition_ZE;
return DEC_Condition_MU; /* Multiple errors */ return DEC_Condition_MU; /* Multiple errors */
} /* decContextStatusToString */ } /* decContextStatusToString */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* decContextTestEndian -- test whether DECLITEND is set correctly */
/* */
/* quiet is 1 to suppress message; 0 otherwise */
/* returns 0 if DECLITEND is correct */
/* 1 if DECLITEND is incorrect and should be 1 */
/* -1 if DECLITEND is incorrect and should be 0 */
/* */
/* A message is displayed if the return value is not 0 and quiet==0. */
/* */
/* No error is possible. */
/* ------------------------------------------------------------------ */
Int decContextTestEndian(Flag quiet) {
Int res=0; /* optimist */
uInt dle=(uInt)DECLITEND; /* unsign */
if (dle>1) dle=1; /* ensure 0 or 1 */
if (LITEND!=DECLITEND) {
const char *adj;
if (!quiet) {
if (LITEND) adj="little";
else adj="big";
printf("Warning: DECLITEND is set to %d, but this computer appears to be %s-endian\n",
DECLITEND, adj);
}
res=(Int)LITEND-dle;
}
return res;
} /* decContextTestEndian */
/* ------------------------------------------------------------------ */
/* decContextTestSavedStatus -- test bits in saved status */ /* decContextTestSavedStatus -- test bits in saved status */
/* */ /* */
/* oldstatus is the status word to be tested */ /* oldstatus is the status word to be tested */
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
/* */ /* */
/* Context variables must always have valid values: */ /* Context variables must always have valid values: */
/* */ /* */
/* status -- [any bits may be cleared, but not set, by user] */ /* status -- [any bits may be cleared, but not set, by user] */
/* round -- must be one of the enumerated rounding modes */ /* round -- must be one of the enumerated rounding modes */
/* */ /* */
/* The following variables are implied for fixed size formats (i.e., */ /* The following variables are implied for fixed size formats (i.e., */
...@@ -54,36 +54,42 @@ ...@@ -54,36 +54,42 @@
#define DECCONTEXT #define DECCONTEXT
#define DECCNAME "decContext" /* Short name */ #define DECCNAME "decContext" /* Short name */
#define DECCFULLNAME "Decimal Context Descriptor" /* Verbose name */ #define DECCFULLNAME "Decimal Context Descriptor" /* Verbose name */
#define DECCAUTHOR "Mike Cowlishaw" /* Who to blame */ #define DECCAUTHOR "Mike Cowlishaw" /* Who to blame */
#include "gstdint.h" /* C99 standard integers */ #if !defined(int32_t)
#include <stdint.h> /* C99 standard integers */
#endif
#include <stdio.h> /* for printf, etc. */ #include <stdio.h> /* for printf, etc. */
#include <signal.h> /* for traps */ #include <signal.h> /* for traps */
/* Extended flags setting -- set this to 0 to use only IEEE flags */ /* Extended flags setting -- set this to 0 to use only IEEE flags */
#if !defined(DECEXTFLAG)
#define DECEXTFLAG 1 /* 1=enable extended flags */ #define DECEXTFLAG 1 /* 1=enable extended flags */
#endif
/* Conditional code flag -- set this to 0 for best performance */ /* Conditional code flag -- set this to 0 for best performance */
#if !defined(DECSUBSET)
#define DECSUBSET 0 /* 1=enable subset arithmetic */ #define DECSUBSET 0 /* 1=enable subset arithmetic */
#endif
/* Context for operations, with associated constants */ /* Context for operations, with associated constants */
enum rounding { enum rounding {
DEC_ROUND_CEILING, /* round towards +infinity */ DEC_ROUND_CEILING, /* round towards +infinity */
DEC_ROUND_UP, /* round away from 0 */ DEC_ROUND_UP, /* round away from 0 */
DEC_ROUND_HALF_UP, /* 0.5 rounds up */ DEC_ROUND_HALF_UP, /* 0.5 rounds up */
DEC_ROUND_HALF_EVEN, /* 0.5 rounds to nearest even */ DEC_ROUND_HALF_EVEN, /* 0.5 rounds to nearest even */
DEC_ROUND_HALF_DOWN, /* 0.5 rounds down */ DEC_ROUND_HALF_DOWN, /* 0.5 rounds down */
DEC_ROUND_DOWN, /* round towards 0 (truncate) */ DEC_ROUND_DOWN, /* round towards 0 (truncate) */
DEC_ROUND_FLOOR, /* round towards -infinity */ DEC_ROUND_FLOOR, /* round towards -infinity */
DEC_ROUND_05UP, /* round for reround */ DEC_ROUND_05UP, /* round for reround */
DEC_ROUND_MAX /* enum must be less than this */ DEC_ROUND_MAX /* enum must be less than this */
}; };
#define DEC_ROUND_DEFAULT DEC_ROUND_HALF_EVEN; #define DEC_ROUND_DEFAULT DEC_ROUND_HALF_EVEN;
typedef struct { typedef struct {
int32_t digits; /* working precision */ int32_t digits; /* working precision */
int32_t emax; /* maximum positive exponent */ int32_t emax; /* maximum positive exponent */
int32_t emin; /* minimum negative exponent */ int32_t emin; /* minimum negative exponent */
enum rounding round; /* rounding mode */ enum rounding round; /* rounding mode */
uint32_t traps; /* trap-enabler flags */ uint32_t traps; /* trap-enabler flags */
uint32_t status; /* status flags */ uint32_t status; /* status flags */
...@@ -102,9 +108,9 @@ ...@@ -102,9 +108,9 @@
#define DEC_MIN_EMIN -999999999 #define DEC_MIN_EMIN -999999999
#define DEC_MAX_MATH 999999 /* max emax, etc., for math funcs. */ #define DEC_MAX_MATH 999999 /* max emax, etc., for math funcs. */
/* Classifications for decimal numbers, aligned with 754r (note */ /* Classifications for decimal numbers, aligned with 754 (note that */
/* that 'normal' and 'subnormal' are meaningful only with a */ /* 'normal' and 'subnormal' are meaningful only with a decContext */
/* decContext or a fixed size format). */ /* or a fixed size format). */
enum decClass { enum decClass {
DEC_CLASS_SNAN, DEC_CLASS_SNAN,
DEC_CLASS_QNAN, DEC_CLASS_QNAN,
...@@ -139,15 +145,15 @@ ...@@ -139,15 +145,15 @@
#define DEC_Division_impossible 0x00000004 #define DEC_Division_impossible 0x00000004
#define DEC_Division_undefined 0x00000008 #define DEC_Division_undefined 0x00000008
#define DEC_Insufficient_storage 0x00000010 /* [when malloc fails] */ #define DEC_Insufficient_storage 0x00000010 /* [when malloc fails] */
#define DEC_Inexact 0x00000020 #define DEC_Inexact 0x00000020
#define DEC_Invalid_context 0x00000040 #define DEC_Invalid_context 0x00000040
#define DEC_Invalid_operation 0x00000080 #define DEC_Invalid_operation 0x00000080
#if DECSUBSET #if DECSUBSET
#define DEC_Lost_digits 0x00000100 #define DEC_Lost_digits 0x00000100
#endif #endif
#define DEC_Overflow 0x00000200 #define DEC_Overflow 0x00000200
#define DEC_Clamped 0x00000400 #define DEC_Clamped 0x00000400
#define DEC_Rounded 0x00000800 #define DEC_Rounded 0x00000800
#define DEC_Subnormal 0x00001000 #define DEC_Subnormal 0x00001000
#define DEC_Underflow 0x00002000 #define DEC_Underflow 0x00002000
#else #else
...@@ -157,43 +163,43 @@ ...@@ -157,43 +163,43 @@
#define DEC_Division_impossible 0x00000010 #define DEC_Division_impossible 0x00000010
#define DEC_Division_undefined 0x00000010 #define DEC_Division_undefined 0x00000010
#define DEC_Insufficient_storage 0x00000010 /* [when malloc fails] */ #define DEC_Insufficient_storage 0x00000010 /* [when malloc fails] */
#define DEC_Inexact 0x00000001 #define DEC_Inexact 0x00000001
#define DEC_Invalid_context 0x00000010 #define DEC_Invalid_context 0x00000010
#define DEC_Invalid_operation 0x00000010 #define DEC_Invalid_operation 0x00000010
#if DECSUBSET #if DECSUBSET
#define DEC_Lost_digits 0x00000000 #define DEC_Lost_digits 0x00000000
#endif #endif
#define DEC_Overflow 0x00000008 #define DEC_Overflow 0x00000008
#define DEC_Clamped 0x00000000 #define DEC_Clamped 0x00000000
#define DEC_Rounded 0x00000000 #define DEC_Rounded 0x00000000
#define DEC_Subnormal 0x00000000 #define DEC_Subnormal 0x00000000
#define DEC_Underflow 0x00000004 #define DEC_Underflow 0x00000004
#endif #endif
/* IEEE 854 groupings for the flags */ /* IEEE 754 groupings for the flags */
/* [DEC_Clamped, DEC_Lost_digits, DEC_Rounded, and DEC_Subnormal */ /* [DEC_Clamped, DEC_Lost_digits, DEC_Rounded, and DEC_Subnormal */
/* are not in IEEE 854] */ /* are not in IEEE 754] */
#define DEC_IEEE_854_Division_by_zero (DEC_Division_by_zero) #define DEC_IEEE_754_Division_by_zero (DEC_Division_by_zero)
#if DECSUBSET #if DECSUBSET
#define DEC_IEEE_854_Inexact (DEC_Inexact | DEC_Lost_digits) #define DEC_IEEE_754_Inexact (DEC_Inexact | DEC_Lost_digits)
#else #else
#define DEC_IEEE_854_Inexact (DEC_Inexact) #define DEC_IEEE_754_Inexact (DEC_Inexact)
#endif #endif
#define DEC_IEEE_854_Invalid_operation (DEC_Conversion_syntax | \ #define DEC_IEEE_754_Invalid_operation (DEC_Conversion_syntax | \
DEC_Division_impossible | \ DEC_Division_impossible | \
DEC_Division_undefined | \ DEC_Division_undefined | \
DEC_Insufficient_storage | \ DEC_Insufficient_storage | \
DEC_Invalid_context | \ DEC_Invalid_context | \
DEC_Invalid_operation) DEC_Invalid_operation)
#define DEC_IEEE_854_Overflow (DEC_Overflow) #define DEC_IEEE_754_Overflow (DEC_Overflow)
#define DEC_IEEE_854_Underflow (DEC_Underflow) #define DEC_IEEE_754_Underflow (DEC_Underflow)
/* flags which are normally errors (result is qNaN, infinite, or 0) */ /* flags which are normally errors (result is qNaN, infinite, or 0) */
#define DEC_Errors (DEC_IEEE_854_Division_by_zero | \ #define DEC_Errors (DEC_IEEE_754_Division_by_zero | \
DEC_IEEE_854_Invalid_operation | \ DEC_IEEE_754_Invalid_operation | \
DEC_IEEE_854_Overflow | DEC_IEEE_854_Underflow) DEC_IEEE_754_Overflow | DEC_IEEE_754_Underflow)
/* flags which cause a result to become qNaN */ /* flags which cause a result to become qNaN */
#define DEC_NaNs DEC_IEEE_854_Invalid_operation #define DEC_NaNs DEC_IEEE_754_Invalid_operation
/* flags which are normally for information only (finite results) */ /* flags which are normally for information only (finite results) */
#if DECSUBSET #if DECSUBSET
...@@ -203,6 +209,13 @@ ...@@ -203,6 +209,13 @@
#define DEC_Information (DEC_Clamped | DEC_Rounded | DEC_Inexact) #define DEC_Information (DEC_Clamped | DEC_Rounded | DEC_Inexact)
#endif #endif
/* IEEE 854 names (for compatibility with older decNumber versions) */
#define DEC_IEEE_854_Division_by_zero DEC_IEEE_754_Division_by_zero
#define DEC_IEEE_854_Inexact DEC_IEEE_754_Inexact
#define DEC_IEEE_854_Invalid_operation DEC_IEEE_754_Invalid_operation
#define DEC_IEEE_854_Overflow DEC_IEEE_754_Overflow
#define DEC_IEEE_854_Underflow DEC_IEEE_754_Underflow
/* Name strings for the exceptional conditions */ /* Name strings for the exceptional conditions */
#define DEC_Condition_CS "Conversion syntax" #define DEC_Condition_CS "Conversion syntax"
#define DEC_Condition_DZ "Division by zero" #define DEC_Condition_DZ "Division by zero"
...@@ -226,7 +239,7 @@ ...@@ -226,7 +239,7 @@
/* including terminator */ /* including terminator */
/* Initialization descriptors, used by decContextDefault */ /* Initialization descriptors, used by decContextDefault */
#define DEC_INIT_BASE 0 #define DEC_INIT_BASE 0
#define DEC_INIT_DECIMAL32 32 #define DEC_INIT_DECIMAL32 32
#define DEC_INIT_DECIMAL64 64 #define DEC_INIT_DECIMAL64 64
#define DEC_INIT_DECIMAL128 128 #define DEC_INIT_DECIMAL128 128
...@@ -251,6 +264,7 @@ ...@@ -251,6 +264,7 @@
extern decContext * decContextSetStatusFromStringQuiet(decContext *, const char *); extern decContext * decContextSetStatusFromStringQuiet(decContext *, const char *);
extern decContext * decContextSetStatusQuiet(decContext *, uint32_t); extern decContext * decContextSetStatusQuiet(decContext *, uint32_t);
extern const char * decContextStatusToString(const decContext *); extern const char * decContextStatusToString(const decContext *);
extern int32_t decContextTestEndian(uint8_t);
extern uint32_t decContextTestSavedStatus(uint32_t, uint32_t); extern uint32_t decContextTestSavedStatus(uint32_t, uint32_t);
extern uint32_t decContextTestStatus(decContext *, uint32_t); extern uint32_t decContextTestStatus(decContext *, uint32_t);
extern decContext * decContextZeroStatus(decContext *); extern decContext * decContextZeroStatus(decContext *);
......
...@@ -30,10 +30,9 @@ ...@@ -30,10 +30,9 @@
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
/* Binary Coded Decimal and Densely Packed Decimal conversion lookup tables */ /* Binary Coded Decimal and Densely Packed Decimal conversion lookup tables */
/* [Automatically generated -- do not edit. 2007.05.05] */ /* [Automatically generated -- do not edit. 2008.06.21] */
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */ /* For details, see DPDecimal.html on the General Decimal Arithmetic page. */
/* For details, see: http://www2.hursley.ibm.com/decimal/DPDecimal.html */
#include "decDPDSymbols.h" #include "decDPDSymbols.h"
...@@ -43,9 +42,9 @@ ...@@ -43,9 +42,9 @@
/* uint16_t BIN2DPD[1000]; -- Bin -> DPD (999 => 2457) */ /* uint16_t BIN2DPD[1000]; -- Bin -> DPD (999 => 2457) */
/* uint8_t BIN2CHAR[4001]; -- Bin -> CHAR (999 => '\3' '9' '9' '9') */ /* uint8_t BIN2CHAR[4001]; -- Bin -> CHAR (999 => '\3' '9' '9' '9') */
/* uint8_t BIN2BCD8[4000]; -- Bin -> bytes (999 => 9 9 9 3) */ /* uint8_t BIN2BCD8[4000]; -- Bin -> bytes (999 => 9 9 9 3) */
/* uint16_t DPD2BCD[1024]; -- DPD -> BCD (0x3FF => 0x999) */ /* uint16_t DPD2BCD[1024]; -- DPD -> BCD (0x3FF => 0x999) */
/* uint16_t DPD2BIN[1024]; -- DPD -> BIN (0x3FF => 999) */ /* uint16_t DPD2BIN[1024]; -- DPD -> BIN (0x3FF => 999) */
/* uint32_t DPD2BINK[1024]; -- DPD -> BIN * 1000 (0x3FF => 999000) */ /* uint32_t DPD2BINK[1024]; -- DPD -> BIN * 1000 (0x3FF => 999000) */
/* uint32_t DPD2BINM[1024]; -- DPD -> BIN * 1E+6 (0x3FF => 999000000) */ /* uint32_t DPD2BINM[1024]; -- DPD -> BIN * 1E+6 (0x3FF => 999000000) */
/* uint8_t DPD2BCD8[4096]; -- DPD -> bytes (x3FF => 9 9 9 3) */ /* uint8_t DPD2BCD8[4096]; -- DPD -> bytes (x3FF => 9 9 9 3) */
/* */ /* */
...@@ -53,10 +52,10 @@ ...@@ -53,10 +52,10 @@
/* in the table entry. BIN2CHAR entries are a single byte length (0 for */ /* in the table entry. BIN2CHAR entries are a single byte length (0 for */
/* value 0) followed by three digit characters; a trailing terminator is */ /* value 0) followed by three digit characters; a trailing terminator is */
/* included to allow 4-char moves always. BIN2BCD8 and DPD2BCD8 entries */ /* included to allow 4-char moves always. BIN2BCD8 and DPD2BCD8 entries */
/* are similar with the three BCD8 digits followed by a one-byte length */ /* are similar with the three BCD8 digits followed by a one-byte length */
/* (again, length=0 for value 0). */ /* (again, length=0 for value 0). */
/* */ /* */
/* To use a table, its name, prefixed with DEC_, must be defined with a */ /* To use a table, its name, prefixed with DEC_, must be defined with a */
/* value of 1 before this header file is included. For example: */ /* value of 1 before this header file is included. For example: */
/* #define DEC_BCD2DPD 1 */ /* #define DEC_BCD2DPD 1 */
/* This mechanism allows software to only include tables that are needed. */ /* This mechanism allows software to only include tables that are needed. */
...@@ -513,7 +512,7 @@ const uint16_t DPD2BIN[1024]={ 0, 1, 2, 3, 4, 5, 6, 7, ...@@ -513,7 +512,7 @@ const uint16_t DPD2BIN[1024]={ 0, 1, 2, 3, 4, 5, 6, 7,
#if defined(DEC_DPD2BINK) && DEC_DPD2BINK==1 && !defined(DECDPD2BINK) #if defined(DEC_DPD2BINK) && DEC_DPD2BINK==1 && !defined(DECDPD2BINK)
#define DECDPD2BINK #define DECDPD2BINK
const uint32_t DPD2BINK[1024]={ 0, 1000, 2000, 3000, 4000, 5000, const uint32_t DPD2BINK[1024]={ 0, 1000, 2000, 3000, 4000, 5000,
6000, 7000, 8000, 9000, 80000, 81000, 800000, 801000, 880000, 881000, 6000, 7000, 8000, 9000, 80000, 81000, 800000, 801000, 880000, 881000,
10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000,
90000, 91000, 810000, 811000, 890000, 891000, 20000, 21000, 22000, 23000, 90000, 91000, 810000, 811000, 890000, 891000, 20000, 21000, 22000, 23000,
...@@ -621,24 +620,24 @@ const uint32_t DPD2BINK[1024]={ 0, 1000, 2000, 3000, 4000, 5000, ...@@ -621,24 +620,24 @@ const uint32_t DPD2BINK[1024]={ 0, 1000, 2000, 3000, 4000, 5000,
#if defined(DEC_DPD2BINM) && DEC_DPD2BINM==1 && !defined(DECDPD2BINM) #if defined(DEC_DPD2BINM) && DEC_DPD2BINM==1 && !defined(DECDPD2BINM)
#define DECDPD2BINM #define DECDPD2BINM
const uint32_t DPD2BINM[1024]={0, 1000000, 2000000, 3000000, 4000000, const uint32_t DPD2BINM[1024]={0, 1000000, 2000000, 3000000, 4000000,
5000000, 6000000, 7000000, 8000000, 9000000, 80000000, 81000000, 5000000, 6000000, 7000000, 8000000, 9000000, 80000000, 81000000,
800000000, 801000000, 880000000, 881000000, 10000000, 11000000, 12000000, 800000000, 801000000, 880000000, 881000000, 10000000, 11000000, 12000000,
13000000, 14000000, 15000000, 16000000, 17000000, 18000000, 19000000, 13000000, 14000000, 15000000, 16000000, 17000000, 18000000, 19000000,
90000000, 91000000, 810000000, 811000000, 890000000, 891000000, 20000000, 90000000, 91000000, 810000000, 811000000, 890000000, 891000000, 20000000,
21000000, 22000000, 23000000, 24000000, 25000000, 26000000, 27000000, 21000000, 22000000, 23000000, 24000000, 25000000, 26000000, 27000000,
28000000, 29000000, 82000000, 83000000, 820000000, 821000000, 808000000, 28000000, 29000000, 82000000, 83000000, 820000000, 821000000, 808000000,
809000000, 30000000, 31000000, 32000000, 33000000, 34000000, 35000000, 809000000, 30000000, 31000000, 32000000, 33000000, 34000000, 35000000,
36000000, 37000000, 38000000, 39000000, 92000000, 93000000, 830000000, 36000000, 37000000, 38000000, 39000000, 92000000, 93000000, 830000000,
831000000, 818000000, 819000000, 40000000, 41000000, 42000000, 43000000, 831000000, 818000000, 819000000, 40000000, 41000000, 42000000, 43000000,
44000000, 45000000, 46000000, 47000000, 48000000, 49000000, 84000000, 44000000, 45000000, 46000000, 47000000, 48000000, 49000000, 84000000,
85000000, 840000000, 841000000, 88000000, 89000000, 50000000, 51000000, 85000000, 840000000, 841000000, 88000000, 89000000, 50000000, 51000000,
52000000, 53000000, 54000000, 55000000, 56000000, 57000000, 58000000, 52000000, 53000000, 54000000, 55000000, 56000000, 57000000, 58000000,
59000000, 94000000, 95000000, 850000000, 851000000, 98000000, 99000000, 59000000, 94000000, 95000000, 850000000, 851000000, 98000000, 99000000,
60000000, 61000000, 62000000, 63000000, 64000000, 65000000, 66000000, 60000000, 61000000, 62000000, 63000000, 64000000, 65000000, 66000000,
67000000, 68000000, 69000000, 86000000, 87000000, 860000000, 861000000, 67000000, 68000000, 69000000, 86000000, 87000000, 860000000, 861000000,
888000000, 889000000, 70000000, 71000000, 72000000, 73000000, 74000000, 888000000, 889000000, 70000000, 71000000, 72000000, 73000000, 74000000,
75000000, 76000000, 77000000, 78000000, 79000000, 96000000, 97000000, 75000000, 76000000, 77000000, 78000000, 79000000, 96000000, 97000000,
870000000, 871000000, 898000000, 899000000, 100000000, 101000000, 102000000, 870000000, 871000000, 898000000, 899000000, 100000000, 101000000, 102000000,
103000000, 104000000, 105000000, 106000000, 107000000, 108000000, 109000000, 103000000, 104000000, 105000000, 106000000, 107000000, 108000000, 109000000,
180000000, 181000000, 900000000, 901000000, 980000000, 981000000, 110000000, 180000000, 181000000, 900000000, 901000000, 980000000, 981000000, 110000000,
......
...@@ -34,19 +34,19 @@ ...@@ -34,19 +34,19 @@
/* This module comprises decDouble operations (including conversions) */ /* This module comprises decDouble operations (including conversions) */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
#include "decContext.h" /* public includes */ #include "decContext.h" /* public includes */
#include "decDouble.h" /* .. */ #include "decDouble.h" /* .. */
/* Constant mappings for shared code */ /* Constant mappings for shared code */
#define DECPMAX DECDOUBLE_Pmax #define DECPMAX DECDOUBLE_Pmax
#define DECEMIN DECDOUBLE_Emin #define DECEMIN DECDOUBLE_Emin
#define DECEMAX DECDOUBLE_Emax #define DECEMAX DECDOUBLE_Emax
#define DECEMAXD DECDOUBLE_EmaxD #define DECEMAXD DECDOUBLE_EmaxD
#define DECBYTES DECDOUBLE_Bytes #define DECBYTES DECDOUBLE_Bytes
#define DECSTRING DECDOUBLE_String #define DECSTRING DECDOUBLE_String
#define DECECONL DECDOUBLE_EconL #define DECECONL DECDOUBLE_EconL
#define DECBIAS DECDOUBLE_Bias #define DECBIAS DECDOUBLE_Bias
#define DECLETS DECDOUBLE_Declets #define DECLETS DECDOUBLE_Declets
#define DECQTINY (-DECDOUBLE_Bias) #define DECQTINY (-DECDOUBLE_Bias)
/* parameters of next-wider format */ /* parameters of next-wider format */
#define DECWBYTES DECQUAD_Bytes #define DECWBYTES DECQUAD_Bytes
...@@ -55,100 +55,98 @@ ...@@ -55,100 +55,98 @@
#define DECWBIAS DECQUAD_Bias #define DECWBIAS DECQUAD_Bias
/* Type and function mappings for shared code */ /* Type and function mappings for shared code */
#define decFloat decDouble /* Type name */ #define decFloat decDouble /* Type name */
#define decFloatWider decQuad /* Type name */ #define decFloatWider decQuad /* Type name */
/* Utilities and conversions (binary results, extractors, etc.) */ /* Utilities and conversions (binary results, extractors, etc.) */
#define decFloatFromBCD decDoubleFromBCD #define decFloatFromBCD decDoubleFromBCD
#define decFloatFromInt32 decDoubleFromInt32 #define decFloatFromInt32 decDoubleFromInt32
#define decFloatFromPacked decDoubleFromPacked #define decFloatFromPacked decDoubleFromPacked
#define decFloatFromString decDoubleFromString #define decFloatFromPackedChecked decDoubleFromPackedChecked
#define decFloatFromUInt32 decDoubleFromUInt32 #define decFloatFromString decDoubleFromString
#define decFloatFromWider decDoubleFromWider #define decFloatFromUInt32 decDoubleFromUInt32
#define decFloatGetCoefficient decDoubleGetCoefficient #define decFloatFromWider decDoubleFromWider
#define decFloatGetExponent decDoubleGetExponent #define decFloatGetCoefficient decDoubleGetCoefficient
#define decFloatSetCoefficient decDoubleSetCoefficient #define decFloatGetExponent decDoubleGetExponent
#define decFloatSetExponent decDoubleSetExponent #define decFloatSetCoefficient decDoubleSetCoefficient
#define decFloatShow decDoubleShow #define decFloatSetExponent decDoubleSetExponent
#define decFloatToBCD decDoubleToBCD #define decFloatShow decDoubleShow
#define decFloatToEngString decDoubleToEngString #define decFloatToBCD decDoubleToBCD
#define decFloatToInt32 decDoubleToInt32 #define decFloatToEngString decDoubleToEngString
#define decFloatToInt32Exact decDoubleToInt32Exact #define decFloatToInt32 decDoubleToInt32
#define decFloatToPacked decDoubleToPacked #define decFloatToInt32Exact decDoubleToInt32Exact
#define decFloatToString decDoubleToString #define decFloatToPacked decDoubleToPacked
#define decFloatToUInt32 decDoubleToUInt32 #define decFloatToString decDoubleToString
#define decFloatToUInt32Exact decDoubleToUInt32Exact #define decFloatToUInt32 decDoubleToUInt32
#define decFloatToWider decDoubleToWider #define decFloatToUInt32Exact decDoubleToUInt32Exact
#define decFloatZero decDoubleZero #define decFloatToWider decDoubleToWider
#define decFloatZero decDoubleZero
/* Computational (result is a decFloat) */ /* Computational (result is a decFloat) */
#define decFloatAbs decDoubleAbs #define decFloatAbs decDoubleAbs
#define decFloatAdd decDoubleAdd #define decFloatAdd decDoubleAdd
#define decFloatAnd decDoubleAnd #define decFloatAnd decDoubleAnd
#define decFloatDivide decDoubleDivide #define decFloatDivide decDoubleDivide
#define decFloatDivideInteger decDoubleDivideInteger #define decFloatDivideInteger decDoubleDivideInteger
#define decFloatFMA decDoubleFMA #define decFloatFMA decDoubleFMA
#define decFloatInvert decDoubleInvert #define decFloatInvert decDoubleInvert
#define decFloatLogB decDoubleLogB #define decFloatLogB decDoubleLogB
#define decFloatMax decDoubleMax #define decFloatMax decDoubleMax
#define decFloatMaxMag decDoubleMaxMag #define decFloatMaxMag decDoubleMaxMag
#define decFloatMin decDoubleMin #define decFloatMin decDoubleMin
#define decFloatMinMag decDoubleMinMag #define decFloatMinMag decDoubleMinMag
#define decFloatMinus decDoubleMinus #define decFloatMinus decDoubleMinus
#define decFloatMultiply decDoubleMultiply #define decFloatMultiply decDoubleMultiply
#define decFloatNextMinus decDoubleNextMinus #define decFloatNextMinus decDoubleNextMinus
#define decFloatNextPlus decDoubleNextPlus #define decFloatNextPlus decDoubleNextPlus
#define decFloatNextToward decDoubleNextToward #define decFloatNextToward decDoubleNextToward
#define decFloatOr decDoubleOr #define decFloatOr decDoubleOr
#define decFloatPlus decDoublePlus #define decFloatPlus decDoublePlus
#define decFloatQuantize decDoubleQuantize #define decFloatQuantize decDoubleQuantize
#define decFloatReduce decDoubleReduce #define decFloatReduce decDoubleReduce
#define decFloatRemainder decDoubleRemainder #define decFloatRemainder decDoubleRemainder
#define decFloatRemainderNear decDoubleRemainderNear #define decFloatRemainderNear decDoubleRemainderNear
#define decFloatRotate decDoubleRotate #define decFloatRotate decDoubleRotate
#define decFloatScaleB decDoubleScaleB #define decFloatScaleB decDoubleScaleB
#define decFloatShift decDoubleShift #define decFloatShift decDoubleShift
#define decFloatSubtract decDoubleSubtract #define decFloatSubtract decDoubleSubtract
#define decFloatToIntegralValue decDoubleToIntegralValue #define decFloatToIntegralValue decDoubleToIntegralValue
#define decFloatToIntegralExact decDoubleToIntegralExact #define decFloatToIntegralExact decDoubleToIntegralExact
#define decFloatXor decDoubleXor #define decFloatXor decDoubleXor
/* Comparisons */ /* Comparisons */
#define decFloatCompare decDoubleCompare #define decFloatCompare decDoubleCompare
#define decFloatCompareSignal decDoubleCompareSignal #define decFloatCompareSignal decDoubleCompareSignal
#define decFloatCompareTotal decDoubleCompareTotal #define decFloatCompareTotal decDoubleCompareTotal
#define decFloatCompareTotalMag decDoubleCompareTotalMag #define decFloatCompareTotalMag decDoubleCompareTotalMag
/* Copies */ /* Copies */
#define decFloatCanonical decDoubleCanonical #define decFloatCanonical decDoubleCanonical
#define decFloatCopy decDoubleCopy #define decFloatCopy decDoubleCopy
#define decFloatCopyAbs decDoubleCopyAbs #define decFloatCopyAbs decDoubleCopyAbs
#define decFloatCopyNegate decDoubleCopyNegate #define decFloatCopyNegate decDoubleCopyNegate
#define decFloatCopySign decDoubleCopySign #define decFloatCopySign decDoubleCopySign
/* Non-computational */ /* Non-computational */
#define decFloatClass decDoubleClass #define decFloatClass decDoubleClass
#define decFloatClassString decDoubleClassString #define decFloatClassString decDoubleClassString
#define decFloatDigits decDoubleDigits #define decFloatDigits decDoubleDigits
#define decFloatIsCanonical decDoubleIsCanonical #define decFloatIsCanonical decDoubleIsCanonical
#define decFloatIsFinite decDoubleIsFinite #define decFloatIsFinite decDoubleIsFinite
#define decFloatIsInfinite decDoubleIsInfinite #define decFloatIsInfinite decDoubleIsInfinite
#define decFloatIsInteger decDoubleIsInteger #define decFloatIsInteger decDoubleIsInteger
#define decFloatIsNaN decDoubleIsNaN #define decFloatIsNaN decDoubleIsNaN
#define decFloatIsNormal decDoubleIsNormal #define decFloatIsNormal decDoubleIsNormal
#define decFloatIsSignaling decDoubleIsSignaling #define decFloatIsSignaling decDoubleIsSignaling
#define decFloatIsSignalling decDoubleIsSignalling #define decFloatIsSignalling decDoubleIsSignalling
#define decFloatIsSigned decDoubleIsSigned #define decFloatIsSigned decDoubleIsSigned
#define decFloatIsSubnormal decDoubleIsSubnormal #define decFloatIsSubnormal decDoubleIsSubnormal
#define decFloatIsZero decDoubleIsZero #define decFloatIsZero decDoubleIsZero
#define decFloatRadix decDoubleRadix #define decFloatRadix decDoubleRadix
#define decFloatSameQuantum decDoubleSameQuantum #define decFloatSameQuantum decDoubleSameQuantum
#define decFloatVersion decDoubleVersion #define decFloatVersion decDoubleVersion
#include "decNumberLocal.h" /* local includes (need DECPMAX) */ #include "decNumberLocal.h" /* local includes (need DECPMAX) */
#include "decCommon.c" /* non-arithmetic decFloat routines */ #include "decCommon.c" /* non-arithmetic decFloat routines */
#include "decBasic.c" /* basic formats routines */ #include "decBasic.c" /* basic formats routines */
/* Below here will move to shared file as completed */
...@@ -31,24 +31,22 @@ ...@@ -31,24 +31,22 @@
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* decDouble.h -- Decimal 64-bit format module header */ /* decDouble.h -- Decimal 64-bit format module header */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* Please see decFloats.h for an overview and documentation details. */
/* ------------------------------------------------------------------ */
#if !defined(DECDOUBLE) #if !defined(DECDOUBLE)
#define DECDOUBLE #define DECDOUBLE
#define DECDOUBLENAME "decimalDouble" /* Short name */ #define DECDOUBLENAME "decimalDouble" /* Short name */
#define DECDOUBLETITLE "Decimal 64-bit datum" /* Verbose name */ #define DECDOUBLETITLE "Decimal 64-bit datum" /* Verbose name */
#define DECDOUBLEAUTHOR "Mike Cowlishaw" /* Who to blame */ #define DECDOUBLEAUTHOR "Mike Cowlishaw" /* Who to blame */
/* parameters for decDoubles */ /* parameters for decDoubles */
#define DECDOUBLE_Bytes 8 /* length */ #define DECDOUBLE_Bytes 8 /* length */
#define DECDOUBLE_Pmax 16 /* maximum precision (digits) */ #define DECDOUBLE_Pmax 16 /* maximum precision (digits) */
#define DECDOUBLE_Emin -383 /* minimum adjusted exponent */ #define DECDOUBLE_Emin -383 /* minimum adjusted exponent */
#define DECDOUBLE_Emax 384 /* maximum adjusted exponent */ #define DECDOUBLE_Emax 384 /* maximum adjusted exponent */
#define DECDOUBLE_EmaxD 3 /* maximum exponent digits */ #define DECDOUBLE_EmaxD 3 /* maximum exponent digits */
#define DECDOUBLE_Bias 398 /* bias for the exponent */ #define DECDOUBLE_Bias 398 /* bias for the exponent */
#define DECDOUBLE_String 25 /* maximum string length, +1 */ #define DECDOUBLE_String 25 /* maximum string length, +1 */
#define DECDOUBLE_EconL 8 /* exponent continuation length */ #define DECDOUBLE_EconL 8 /* exponent continuation length */
#define DECDOUBLE_Declets 5 /* count of declets */ #define DECDOUBLE_Declets 5 /* count of declets */
/* highest biased exponent (Elimit-1) */ /* highest biased exponent (Elimit-1) */
...@@ -58,11 +56,14 @@ ...@@ -58,11 +56,14 @@
#include "decContext.h" #include "decContext.h"
#include "decQuad.h" #include "decQuad.h"
/* The decDouble decimal 64-bit type, accessible by various types */ /* The decDouble decimal 64-bit type, accessible by all sizes */
typedef union { typedef union {
uint8_t bytes[DECDOUBLE_Bytes]; /* fields: 1, 5, 8, 50 bits */ uint8_t bytes[DECDOUBLE_Bytes]; /* fields: 1, 5, 8, 50 bits */
uint16_t shorts[DECDOUBLE_Bytes/2]; uint16_t shorts[DECDOUBLE_Bytes/2];
uint32_t words[DECDOUBLE_Bytes/4]; uint32_t words[DECDOUBLE_Bytes/4];
#if DECUSE64
uint64_t longs[DECDOUBLE_Bytes/8];
#endif
} decDouble; } decDouble;
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
...@@ -75,6 +76,7 @@ ...@@ -75,6 +76,7 @@
extern decDouble * decDoubleFromBCD(decDouble *, int32_t, const uint8_t *, int32_t); extern decDouble * decDoubleFromBCD(decDouble *, int32_t, const uint8_t *, int32_t);
extern decDouble * decDoubleFromInt32(decDouble *, int32_t); extern decDouble * decDoubleFromInt32(decDouble *, int32_t);
extern decDouble * decDoubleFromPacked(decDouble *, int32_t, const uint8_t *); extern decDouble * decDoubleFromPacked(decDouble *, int32_t, const uint8_t *);
extern decDouble * decDoubleFromPackedChecked(decDouble *, int32_t, const uint8_t *);
extern decDouble * decDoubleFromString(decDouble *, const char *, decContext *); extern decDouble * decDoubleFromString(decDouble *, const char *, decContext *);
extern decDouble * decDoubleFromUInt32(decDouble *, uint32_t); extern decDouble * decDoubleFromUInt32(decDouble *, uint32_t);
extern decDouble * decDoubleFromWider(decDouble *, const decQuad *, decContext *); extern decDouble * decDoubleFromWider(decDouble *, const decQuad *, decContext *);
...@@ -160,7 +162,8 @@ ...@@ -160,7 +162,8 @@
/* decNumber conversions; these are implemented as macros so as not */ /* decNumber conversions; these are implemented as macros so as not */
/* to force a dependency on decimal64 and decNumber in decDouble. */ /* to force a dependency on decimal64 and decNumber in decDouble. */
/* decDoubleFromNumber returns a decimal64 * to avoid warnings. */
#define decDoubleToNumber(dq, dn) decimal64ToNumber((decimal64 *)(dq), dn) #define decDoubleToNumber(dq, dn) decimal64ToNumber((decimal64 *)(dq), dn)
#define decDoubleFromNumber(dq, dn, set) (decDouble *)decimal64FromNumber((decimal64 *)(dq), dn, set) #define decDoubleFromNumber(dq, dn, set) decimal64FromNumber((decimal64 *)(dq), dn, set)
#endif #endif
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#define DECNEG 0x80 /* Sign; 1=negative, 0=positive or zero */ #define DECNEG 0x80 /* Sign; 1=negative, 0=positive or zero */
#define DECINF 0x40 /* 1=Infinity */ #define DECINF 0x40 /* 1=Infinity */
#define DECNAN 0x20 /* 1=NaN */ #define DECNAN 0x20 /* 1=NaN */
#define DECSNAN 0x10 /* 1=sNaN */ #define DECSNAN 0x10 /* 1=sNaN */
/* The remaining bits are reserved; they must be 0 */ /* The remaining bits are reserved; they must be 0 */
#define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value */ #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value */
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
uint8_t * decNumberGetBCD(const decNumber *, uint8_t *); uint8_t * decNumberGetBCD(const decNumber *, uint8_t *);
decNumber * decNumberSetBCD(decNumber *, const uint8_t *, uint32_t); decNumber * decNumberSetBCD(decNumber *, const uint8_t *, uint32_t);
/* Operators and elementary functions */ /* Operators and elementary functions */
decNumber * decNumberAbs(decNumber *, const decNumber *, decContext *); decNumber * decNumberAbs(decNumber *, const decNumber *, decContext *);
decNumber * decNumberAdd(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberAdd(decNumber *, const decNumber *, const decNumber *, decContext *);
decNumber * decNumberAnd(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberAnd(decNumber *, const decNumber *, const decNumber *, decContext *);
...@@ -185,7 +185,7 @@ ...@@ -185,7 +185,7 @@
/* Macros for testing decNumber *dn */ /* Macros for testing decNumber *dn */
#define decNumberIsCanonical(dn) (1) /* All decNumbers are saintly */ #define decNumberIsCanonical(dn) (1) /* All decNumbers are saintly */
#define decNumberIsFinite(dn) (((dn)->bits&DECSPECIAL)==0) #define decNumberIsFinite(dn) (((dn)->bits&DECSPECIAL)==0)
#define decNumberIsInfinite(dn) (((dn)->bits&DECINF)!=0) #define decNumberIsInfinite(dn) (((dn)->bits&DECINF)!=0)
#define decNumberIsNaN(dn) (((dn)->bits&(DECNAN|DECSNAN))!=0) #define decNumberIsNaN(dn) (((dn)->bits&(DECNAN|DECSNAN))!=0)
#define decNumberIsNegative(dn) (((dn)->bits&DECNEG)!=0) #define decNumberIsNegative(dn) (((dn)->bits&DECNEG)!=0)
......
...@@ -31,12 +31,12 @@ ...@@ -31,12 +31,12 @@
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* Packed Decimal conversion module */ /* Packed Decimal conversion module */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* This module comprises the routines for Packed Decimal format */ /* This module comprises the routines for Packed Decimal format */
/* numbers. Conversions are supplied to and from decNumber, which in */ /* numbers. Conversions are supplied to and from decNumber, which in */
/* turn supports: */ /* turn supports: */
/* conversions to and from string */ /* conversions to and from string */
/* arithmetic routines */ /* arithmetic routines */
/* utilities. */ /* utilities. */
/* Conversions from decNumber to and from densely packed decimal */ /* Conversions from decNumber to and from densely packed decimal */
/* formats are provided by the decimal32 through decimal128 modules. */ /* formats are provided by the decimal32 through decimal128 modules. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
/* */ /* */
/* bcd is the BCD bytes */ /* bcd is the BCD bytes */
/* length is the length of the BCD array */ /* length is the length of the BCD array */
/* scale is the scale result */ /* scale is the scale result */
/* dn is the decNumber */ /* dn is the decNumber */
/* returns bcd, or NULL if error */ /* returns bcd, or NULL if error */
/* */ /* */
/* The number is converted to a BCD packed decimal byte array, */ /* The number is converted to a BCD packed decimal byte array, */
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
/* as necessary. */ /* as necessary. */
/* */ /* */
/* If there is an error (that is, the decNumber has too many digits */ /* If there is an error (that is, the decNumber has too many digits */
/* to fit in length bytes, or it is a NaN or Infinity), NULL is */ /* to fit in length bytes, or it is a NaN or Infinity), NULL is */
/* returned and the bcd and scale results are unchanged. Otherwise */ /* returned and the bcd and scale results are unchanged. Otherwise */
/* bcd is returned. */ /* bcd is returned. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
...@@ -86,9 +86,9 @@ uByte * decPackedFromNumber(uByte *bcd, Int length, Int *scale, ...@@ -86,9 +86,9 @@ uByte * decPackedFromNumber(uByte *bcd, Int length, Int *scale,
if (dn->digits>length*2-1 /* too long .. */ if (dn->digits>length*2-1 /* too long .. */
||(dn->bits & DECSPECIAL)) return NULL; /* .. or special -- hopeless */ ||(dn->bits & DECSPECIAL)) return NULL; /* .. or special -- hopeless */
if (dn->bits&DECNEG) obyte=DECPMINUS; /* set the sign .. */ if (dn->bits&DECNEG) obyte=DECPMINUS; /* set the sign .. */
else obyte=DECPPLUS; else obyte=DECPPLUS;
*scale=-dn->exponent; /* .. and scale */ *scale=-dn->exponent; /* .. and scale */
/* loop from lowest (rightmost) byte */ /* loop from lowest (rightmost) byte */
out=bcd+length-1; /* -> final byte */ out=bcd+length-1; /* -> final byte */
...@@ -141,7 +141,7 @@ uByte * decPackedFromNumber(uByte *bcd, Int length, Int *scale, ...@@ -141,7 +141,7 @@ uByte * decPackedFromNumber(uByte *bcd, Int length, Int *scale,
/* bcd is the BCD bytes */ /* bcd is the BCD bytes */
/* length is the length of the BCD array */ /* length is the length of the BCD array */
/* scale is the scale associated with the BCD integer */ /* scale is the scale associated with the BCD integer */
/* dn is the decNumber [with space for length*2 digits] */ /* dn is the decNumber [with space for length*2 digits] */
/* returns dn, or NULL if error */ /* returns dn, or NULL if error */
/* */ /* */
/* The BCD packed decimal byte array, together with an associated */ /* The BCD packed decimal byte array, together with an associated */
...@@ -157,7 +157,7 @@ uByte * decPackedFromNumber(uByte *bcd, Int length, Int *scale, ...@@ -157,7 +157,7 @@ uByte * decPackedFromNumber(uByte *bcd, Int length, Int *scale,
/* no error is possible unless the adjusted exponent is out of range, */ /* no error is possible unless the adjusted exponent is out of range, */
/* no sign nibble was found, or a sign nibble was found before the */ /* no sign nibble was found, or a sign nibble was found before the */
/* final nibble. In these error cases, NULL is returned and the */ /* final nibble. In these error cases, NULL is returned and the */
/* decNumber will be 0. */ /* decNumber will be 0. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
decNumber * decPackedToNumber(const uByte *bcd, Int length, decNumber * decPackedToNumber(const uByte *bcd, Int length,
const Int *scale, decNumber *dn) { const Int *scale, decNumber *dn) {
...@@ -165,7 +165,7 @@ decNumber * decPackedToNumber(const uByte *bcd, Int length, ...@@ -165,7 +165,7 @@ decNumber * decPackedToNumber(const uByte *bcd, Int length,
const uByte *first; /* -> first non-zero byte */ const uByte *first; /* -> first non-zero byte */
uInt nib; /* work nibble */ uInt nib; /* work nibble */
Unit *up=dn->lsu; /* output pointer */ Unit *up=dn->lsu; /* output pointer */
Int digits; /* digits count */ Int digits; /* digits count */
Int cut=0; /* phase of output */ Int cut=0; /* phase of output */
decNumberZero(dn); /* default result */ decNumberZero(dn); /* default result */
...@@ -182,7 +182,7 @@ decNumber * decPackedToNumber(const uByte *bcd, Int length, ...@@ -182,7 +182,7 @@ decNumber * decPackedToNumber(const uByte *bcd, Int length,
/* leave as 1] */ /* leave as 1] */
/* check the adjusted exponent; note that scale could be unbounded */ /* check the adjusted exponent; note that scale could be unbounded */
dn->exponent=-*scale; /* set the exponent */ dn->exponent=-*scale; /* set the exponent */
if (*scale>=0) { /* usual case */ if (*scale>=0) { /* usual case */
if ((dn->digits-*scale-1)<-DECNUMMAXE) { /* underflow */ if ((dn->digits-*scale-1)<-DECNUMMAXE) { /* underflow */
decNumberZero(dn); decNumberZero(dn);
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#define DECPACKED #define DECPACKED
#define DECPNAME "decPacked" /* Short name */ #define DECPNAME "decPacked" /* Short name */
#define DECPFULLNAME "Packed Decimal conversions" /* Verbose name */ #define DECPFULLNAME "Packed Decimal conversions" /* Verbose name */
#define DECPAUTHOR "Mike Cowlishaw" /* Who to blame */ #define DECPAUTHOR "Mike Cowlishaw" /* Who to blame */
#define DECPACKED_DefP 32 /* default precision */ #define DECPACKED_DefP 32 /* default precision */
...@@ -47,12 +47,12 @@ ...@@ -47,12 +47,12 @@
/* Sign nibble constants */ /* Sign nibble constants */
#if !defined(DECPPLUSALT) #if !defined(DECPPLUSALT)
#define DECPPLUSALT 0x0A /* alternate plus nibble */ #define DECPPLUSALT 0x0A /* alternate plus nibble */
#define DECPMINUSALT 0x0B /* alternate minus nibble */ #define DECPMINUSALT 0x0B /* alternate minus nibble */
#define DECPPLUS 0x0C /* preferred plus nibble */ #define DECPPLUS 0x0C /* preferred plus nibble */
#define DECPMINUS 0x0D /* preferred minus nibble */ #define DECPMINUS 0x0D /* preferred minus nibble */
#define DECPPLUSALT2 0x0E /* alternate plus nibble */ #define DECPPLUSALT2 0x0E /* alternate plus nibble */
#define DECPUNSIGNED 0x0F /* alternate plus nibble (unsigned) */ #define DECPUNSIGNED 0x0F /* alternate plus nibble (unsigned) */
#endif #endif
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
......
...@@ -34,111 +34,111 @@ ...@@ -34,111 +34,111 @@
/* This module comprises decQuad operations (including conversions) */ /* This module comprises decQuad operations (including conversions) */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
#include "decContext.h" /* public includes */ #include "decContext.h" /* public includes */
#include "decQuad.h" /* .. */ #include "decQuad.h" /* .. */
/* Constant mappings for shared code */ /* Constant mappings for shared code */
#define DECPMAX DECQUAD_Pmax #define DECPMAX DECQUAD_Pmax
#define DECEMIN DECQUAD_Emin #define DECEMIN DECQUAD_Emin
#define DECEMAX DECQUAD_Emax #define DECEMAX DECQUAD_Emax
#define DECEMAXD DECQUAD_EmaxD #define DECEMAXD DECQUAD_EmaxD
#define DECBYTES DECQUAD_Bytes #define DECBYTES DECQUAD_Bytes
#define DECSTRING DECQUAD_String #define DECSTRING DECQUAD_String
#define DECECONL DECQUAD_EconL #define DECECONL DECQUAD_EconL
#define DECBIAS DECQUAD_Bias #define DECBIAS DECQUAD_Bias
#define DECLETS DECQUAD_Declets #define DECLETS DECQUAD_Declets
#define DECQTINY (-DECQUAD_Bias) #define DECQTINY (-DECQUAD_Bias)
/* Type and function mappings for shared code */ /* Type and function mappings for shared code */
#define decFloat decQuad /* Type name */ #define decFloat decQuad /* Type name */
/* Utilities and conversions (binary results, extractors, etc.) */ /* Utilities and conversions (binary results, extractors, etc.) */
#define decFloatFromBCD decQuadFromBCD #define decFloatFromBCD decQuadFromBCD
#define decFloatFromInt32 decQuadFromInt32 #define decFloatFromInt32 decQuadFromInt32
#define decFloatFromPacked decQuadFromPacked #define decFloatFromPacked decQuadFromPacked
#define decFloatFromString decQuadFromString #define decFloatFromPackedChecked decQuadFromPackedChecked
#define decFloatFromUInt32 decQuadFromUInt32 #define decFloatFromString decQuadFromString
#define decFloatFromWider decQuadFromWider #define decFloatFromUInt32 decQuadFromUInt32
#define decFloatGetCoefficient decQuadGetCoefficient #define decFloatFromWider decQuadFromWider
#define decFloatGetExponent decQuadGetExponent #define decFloatGetCoefficient decQuadGetCoefficient
#define decFloatSetCoefficient decQuadSetCoefficient #define decFloatGetExponent decQuadGetExponent
#define decFloatSetExponent decQuadSetExponent #define decFloatSetCoefficient decQuadSetCoefficient
#define decFloatShow decQuadShow #define decFloatSetExponent decQuadSetExponent
#define decFloatToBCD decQuadToBCD #define decFloatShow decQuadShow
#define decFloatToEngString decQuadToEngString #define decFloatToBCD decQuadToBCD
#define decFloatToInt32 decQuadToInt32 #define decFloatToEngString decQuadToEngString
#define decFloatToInt32Exact decQuadToInt32Exact #define decFloatToInt32 decQuadToInt32
#define decFloatToPacked decQuadToPacked #define decFloatToInt32Exact decQuadToInt32Exact
#define decFloatToString decQuadToString #define decFloatToPacked decQuadToPacked
#define decFloatToUInt32 decQuadToUInt32 #define decFloatToString decQuadToString
#define decFloatToUInt32Exact decQuadToUInt32Exact #define decFloatToUInt32 decQuadToUInt32
#define decFloatToWider decQuadToWider #define decFloatToUInt32Exact decQuadToUInt32Exact
#define decFloatZero decQuadZero #define decFloatToWider decQuadToWider
#define decFloatZero decQuadZero
/* Computational (result is a decFloat) */ /* Computational (result is a decFloat) */
#define decFloatAbs decQuadAbs #define decFloatAbs decQuadAbs
#define decFloatAdd decQuadAdd #define decFloatAdd decQuadAdd
#define decFloatAnd decQuadAnd #define decFloatAnd decQuadAnd
#define decFloatDivide decQuadDivide #define decFloatDivide decQuadDivide
#define decFloatDivideInteger decQuadDivideInteger #define decFloatDivideInteger decQuadDivideInteger
#define decFloatFMA decQuadFMA #define decFloatFMA decQuadFMA
#define decFloatInvert decQuadInvert #define decFloatInvert decQuadInvert
#define decFloatLogB decQuadLogB #define decFloatLogB decQuadLogB
#define decFloatMax decQuadMax #define decFloatMax decQuadMax
#define decFloatMaxMag decQuadMaxMag #define decFloatMaxMag decQuadMaxMag
#define decFloatMin decQuadMin #define decFloatMin decQuadMin
#define decFloatMinMag decQuadMinMag #define decFloatMinMag decQuadMinMag
#define decFloatMinus decQuadMinus #define decFloatMinus decQuadMinus
#define decFloatMultiply decQuadMultiply #define decFloatMultiply decQuadMultiply
#define decFloatNextMinus decQuadNextMinus #define decFloatNextMinus decQuadNextMinus
#define decFloatNextPlus decQuadNextPlus #define decFloatNextPlus decQuadNextPlus
#define decFloatNextToward decQuadNextToward #define decFloatNextToward decQuadNextToward
#define decFloatOr decQuadOr #define decFloatOr decQuadOr
#define decFloatPlus decQuadPlus #define decFloatPlus decQuadPlus
#define decFloatQuantize decQuadQuantize #define decFloatQuantize decQuadQuantize
#define decFloatReduce decQuadReduce #define decFloatReduce decQuadReduce
#define decFloatRemainder decQuadRemainder #define decFloatRemainder decQuadRemainder
#define decFloatRemainderNear decQuadRemainderNear #define decFloatRemainderNear decQuadRemainderNear
#define decFloatRotate decQuadRotate #define decFloatRotate decQuadRotate
#define decFloatScaleB decQuadScaleB #define decFloatScaleB decQuadScaleB
#define decFloatShift decQuadShift #define decFloatShift decQuadShift
#define decFloatSubtract decQuadSubtract #define decFloatSubtract decQuadSubtract
#define decFloatToIntegralValue decQuadToIntegralValue #define decFloatToIntegralValue decQuadToIntegralValue
#define decFloatToIntegralExact decQuadToIntegralExact #define decFloatToIntegralExact decQuadToIntegralExact
#define decFloatXor decQuadXor #define decFloatXor decQuadXor
/* Comparisons */ /* Comparisons */
#define decFloatCompare decQuadCompare #define decFloatCompare decQuadCompare
#define decFloatCompareSignal decQuadCompareSignal #define decFloatCompareSignal decQuadCompareSignal
#define decFloatCompareTotal decQuadCompareTotal #define decFloatCompareTotal decQuadCompareTotal
#define decFloatCompareTotalMag decQuadCompareTotalMag #define decFloatCompareTotalMag decQuadCompareTotalMag
/* Copies */ /* Copies */
#define decFloatCanonical decQuadCanonical #define decFloatCanonical decQuadCanonical
#define decFloatCopy decQuadCopy #define decFloatCopy decQuadCopy
#define decFloatCopyAbs decQuadCopyAbs #define decFloatCopyAbs decQuadCopyAbs
#define decFloatCopyNegate decQuadCopyNegate #define decFloatCopyNegate decQuadCopyNegate
#define decFloatCopySign decQuadCopySign #define decFloatCopySign decQuadCopySign
/* Non-computational */ /* Non-computational */
#define decFloatClass decQuadClass #define decFloatClass decQuadClass
#define decFloatClassString decQuadClassString #define decFloatClassString decQuadClassString
#define decFloatDigits decQuadDigits #define decFloatDigits decQuadDigits
#define decFloatIsCanonical decQuadIsCanonical #define decFloatIsCanonical decQuadIsCanonical
#define decFloatIsFinite decQuadIsFinite #define decFloatIsFinite decQuadIsFinite
#define decFloatIsInfinite decQuadIsInfinite #define decFloatIsInfinite decQuadIsInfinite
#define decFloatIsInteger decQuadIsInteger #define decFloatIsInteger decQuadIsInteger
#define decFloatIsNaN decQuadIsNaN #define decFloatIsNaN decQuadIsNaN
#define decFloatIsNormal decQuadIsNormal #define decFloatIsNormal decQuadIsNormal
#define decFloatIsSignaling decQuadIsSignaling #define decFloatIsSignaling decQuadIsSignaling
#define decFloatIsSignalling decQuadIsSignalling #define decFloatIsSignalling decQuadIsSignalling
#define decFloatIsSigned decQuadIsSigned #define decFloatIsSigned decQuadIsSigned
#define decFloatIsSubnormal decQuadIsSubnormal #define decFloatIsSubnormal decQuadIsSubnormal
#define decFloatIsZero decQuadIsZero #define decFloatIsZero decQuadIsZero
#define decFloatRadix decQuadRadix #define decFloatRadix decQuadRadix
#define decFloatSameQuantum decQuadSameQuantum #define decFloatSameQuantum decQuadSameQuantum
#define decFloatVersion decQuadVersion #define decFloatVersion decQuadVersion
#include "decNumberLocal.h" /* local includes (need DECPMAX) */ #include "decNumberLocal.h" /* local includes (need DECPMAX) */
#include "decCommon.c" /* non-arithmetic decFloat routines */ #include "decCommon.c" /* non-arithmetic decFloat routines */
......
...@@ -31,27 +31,25 @@ ...@@ -31,27 +31,25 @@
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* decQuad.h -- Decimal 128-bit format module header */ /* decQuad.h -- Decimal 128-bit format module header */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* Please see decFloats.h for an overview and documentation details. */
/* ------------------------------------------------------------------ */
/* This include file is always included by decSingle and decDouble, */ /* This include file is always included by decSingle and decDouble, */
/* and therefore also holds useful constants used by all three. */ /* and therefore also holds useful constants used by all three. */
#if !defined(DECQUAD) #if !defined(DECQUAD)
#define DECQUAD #define DECQUAD
#define DECQUADNAME "decimalQuad" /* Short name */ #define DECQUADNAME "decimalQuad" /* Short name */
#define DECQUADTITLE "Decimal 128-bit datum" /* Verbose name */ #define DECQUADTITLE "Decimal 128-bit datum" /* Verbose name */
#define DECQUADAUTHOR "Mike Cowlishaw" /* Who to blame */ #define DECQUADAUTHOR "Mike Cowlishaw" /* Who to blame */
/* parameters for decQuads */ /* parameters for decQuads */
#define DECQUAD_Bytes 16 /* length */ #define DECQUAD_Bytes 16 /* length */
#define DECQUAD_Pmax 34 /* maximum precision (digits) */ #define DECQUAD_Pmax 34 /* maximum precision (digits) */
#define DECQUAD_Emin -6143 /* minimum adjusted exponent */ #define DECQUAD_Emin -6143 /* minimum adjusted exponent */
#define DECQUAD_Emax 6144 /* maximum adjusted exponent */ #define DECQUAD_Emax 6144 /* maximum adjusted exponent */
#define DECQUAD_EmaxD 4 /* maximum exponent digits */ #define DECQUAD_EmaxD 4 /* maximum exponent digits */
#define DECQUAD_Bias 6176 /* bias for the exponent */ #define DECQUAD_Bias 6176 /* bias for the exponent */
#define DECQUAD_String 43 /* maximum string length, +1 */ #define DECQUAD_String 43 /* maximum string length, +1 */
#define DECQUAD_EconL 12 /* exponent continuation length */ #define DECQUAD_EconL 12 /* exponent continuation length */
#define DECQUAD_Declets 11 /* count of declets */ #define DECQUAD_Declets 11 /* count of declets */
/* highest biased exponent (Elimit-1) */ /* highest biased exponent (Elimit-1) */
#define DECQUAD_Ehigh (DECQUAD_Emax + DECQUAD_Bias - (DECQUAD_Pmax-1)) #define DECQUAD_Ehigh (DECQUAD_Emax + DECQUAD_Bias - (DECQUAD_Pmax-1))
...@@ -59,11 +57,14 @@ ...@@ -59,11 +57,14 @@
/* Required include */ /* Required include */
#include "decContext.h" #include "decContext.h"
/* The decQuad decimal 128-bit type, accessible by various types */ /* The decQuad decimal 128-bit type, accessible by all sizes */
typedef union { typedef union {
uint8_t bytes[DECQUAD_Bytes]; /* fields: 1, 5, 12, 110 bits */ uint8_t bytes[DECQUAD_Bytes]; /* fields: 1, 5, 12, 110 bits */
uint16_t shorts[DECQUAD_Bytes/2]; uint16_t shorts[DECQUAD_Bytes/2];
uint32_t words[DECQUAD_Bytes/4]; uint32_t words[DECQUAD_Bytes/4];
#if DECUSE64
uint64_t longs[DECQUAD_Bytes/8];
#endif
} decQuad; } decQuad;
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
...@@ -72,21 +73,21 @@ ...@@ -72,21 +73,21 @@
/* sign and special values [top 32-bits; last two bits are don't-care /* sign and special values [top 32-bits; last two bits are don't-care
for Infinity on input, last bit don't-care for NaNs] */ for Infinity on input, last bit don't-care for NaNs] */
#define DECFLOAT_Sign 0x80000000 /* 1 00000 00 Sign */ #define DECFLOAT_Sign 0x80000000 /* 1 00000 00 Sign */
#define DECFLOAT_NaN 0x7c000000 /* 0 11111 00 NaN generic */ #define DECFLOAT_NaN 0x7c000000 /* 0 11111 00 NaN generic */
#define DECFLOAT_qNaN 0x7c000000 /* 0 11111 00 qNaN */ #define DECFLOAT_qNaN 0x7c000000 /* 0 11111 00 qNaN */
#define DECFLOAT_sNaN 0x7e000000 /* 0 11111 10 sNaN */ #define DECFLOAT_sNaN 0x7e000000 /* 0 11111 10 sNaN */
#define DECFLOAT_Inf 0x78000000 /* 0 11110 00 Infinity */ #define DECFLOAT_Inf 0x78000000 /* 0 11110 00 Infinity */
#define DECFLOAT_MinSp 0x78000000 /* minimum special value */ #define DECFLOAT_MinSp 0x78000000 /* minimum special value */
/* [specials are all >=MinSp] */ /* [specials are all >=MinSp] */
/* Sign nibble constants */ /* Sign nibble constants */
#if !defined(DECPPLUSALT) #if !defined(DECPPLUSALT)
#define DECPPLUSALT 0x0A /* alternate plus nibble */ #define DECPPLUSALT 0x0A /* alternate plus nibble */
#define DECPMINUSALT 0x0B /* alternate minus nibble */ #define DECPMINUSALT 0x0B /* alternate minus nibble */
#define DECPPLUS 0x0C /* preferred plus nibble */ #define DECPPLUS 0x0C /* preferred plus nibble */
#define DECPMINUS 0x0D /* preferred minus nibble */ #define DECPMINUS 0x0D /* preferred minus nibble */
#define DECPPLUSALT2 0x0E /* alternate plus nibble */ #define DECPPLUSALT2 0x0E /* alternate plus nibble */
#define DECPUNSIGNED 0x0F /* alternate plus nibble (unsigned) */ #define DECPUNSIGNED 0x0F /* alternate plus nibble (unsigned) */
#endif #endif
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
...@@ -99,6 +100,7 @@ ...@@ -99,6 +100,7 @@
extern decQuad * decQuadFromBCD(decQuad *, int32_t, const uint8_t *, int32_t); extern decQuad * decQuadFromBCD(decQuad *, int32_t, const uint8_t *, int32_t);
extern decQuad * decQuadFromInt32(decQuad *, int32_t); extern decQuad * decQuadFromInt32(decQuad *, int32_t);
extern decQuad * decQuadFromPacked(decQuad *, int32_t, const uint8_t *); extern decQuad * decQuadFromPacked(decQuad *, int32_t, const uint8_t *);
extern decQuad * decQuadFromPackedChecked(decQuad *, int32_t, const uint8_t *);
extern decQuad * decQuadFromString(decQuad *, const char *, decContext *); extern decQuad * decQuadFromString(decQuad *, const char *, decContext *);
extern decQuad * decQuadFromUInt32(decQuad *, uint32_t); extern decQuad * decQuadFromUInt32(decQuad *, uint32_t);
extern int32_t decQuadGetCoefficient(const decQuad *, uint8_t *); extern int32_t decQuadGetCoefficient(const decQuad *, uint8_t *);
...@@ -182,7 +184,8 @@ ...@@ -182,7 +184,8 @@
/* decNumber conversions; these are implemented as macros so as not */ /* decNumber conversions; these are implemented as macros so as not */
/* to force a dependency on decimal128 and decNumber in decQuad. */ /* to force a dependency on decimal128 and decNumber in decQuad. */
/* decQuadFromNumber returns a decimal128 * to avoid warnings. */
#define decQuadToNumber(dq, dn) decimal128ToNumber((decimal128 *)(dq), dn) #define decQuadToNumber(dq, dn) decimal128ToNumber((decimal128 *)(dq), dn)
#define decQuadFromNumber(dq, dn, set) (decQuad *)decimal128FromNumber((decimal128 *)(dq), dn, set) #define decQuadFromNumber(dq, dn, set) decimal128FromNumber((decimal128 *)(dq), dn, set)
#endif #endif
...@@ -31,22 +31,20 @@ ...@@ -31,22 +31,20 @@
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* decSingle.c -- decSingle operations module */ /* decSingle.c -- decSingle operations module */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* This module comprises decSingle operations (including conversions) */
/* ------------------------------------------------------------------ */
#include "decContext.h" /* public includes */ #include "decContext.h" /* public includes */
#include "decSingle.h" /* public includes */ #include "decSingle.h" /* public includes */
/* Constant mappings for shared code */ /* Constant mappings for shared code */
#define DECPMAX DECSINGLE_Pmax #define DECPMAX DECSINGLE_Pmax
#define DECEMIN DECSINGLE_Emin #define DECEMIN DECSINGLE_Emin
#define DECEMAX DECSINGLE_Emax #define DECEMAX DECSINGLE_Emax
#define DECEMAXD DECSINGLE_EmaxD #define DECEMAXD DECSINGLE_EmaxD
#define DECBYTES DECSINGLE_Bytes #define DECBYTES DECSINGLE_Bytes
#define DECSTRING DECSINGLE_String #define DECSTRING DECSINGLE_String
#define DECECONL DECSINGLE_EconL #define DECECONL DECSINGLE_EconL
#define DECBIAS DECSINGLE_Bias #define DECBIAS DECSINGLE_Bias
#define DECLETS DECSINGLE_Declets #define DECLETS DECSINGLE_Declets
#define DECQTINY (-DECSINGLE_Bias) #define DECQTINY (-DECSINGLE_Bias)
/* parameters of next-wider format */ /* parameters of next-wider format */
#define DECWBYTES DECDOUBLE_Bytes #define DECWBYTES DECDOUBLE_Bytes
...@@ -55,29 +53,30 @@ ...@@ -55,29 +53,30 @@
#define DECWBIAS DECDOUBLE_Bias #define DECWBIAS DECDOUBLE_Bias
/* Type and function mappings for shared code */ /* Type and function mappings for shared code */
#define decFloat decSingle /* Type name */ #define decFloat decSingle /* Type name */
#define decFloatWider decDouble /* Type name */ #define decFloatWider decDouble /* Type name */
/* Utility (binary results, extractors, etc.) */ /* Utility (binary results, extractors, etc.) */
#define decFloatFromBCD decSingleFromBCD #define decFloatFromBCD decSingleFromBCD
#define decFloatFromPacked decSingleFromPacked #define decFloatFromPacked decSingleFromPacked
#define decFloatFromString decSingleFromString #define decFloatFromPackedChecked decSingleFromPackedChecked
#define decFloatFromWider decSingleFromWider #define decFloatFromString decSingleFromString
#define decFloatGetCoefficient decSingleGetCoefficient #define decFloatFromWider decSingleFromWider
#define decFloatGetExponent decSingleGetExponent #define decFloatGetCoefficient decSingleGetCoefficient
#define decFloatSetCoefficient decSingleSetCoefficient #define decFloatGetExponent decSingleGetExponent
#define decFloatSetExponent decSingleSetExponent #define decFloatSetCoefficient decSingleSetCoefficient
#define decFloatShow decSingleShow #define decFloatSetExponent decSingleSetExponent
#define decFloatToBCD decSingleToBCD #define decFloatShow decSingleShow
#define decFloatToEngString decSingleToEngString #define decFloatToBCD decSingleToBCD
#define decFloatToPacked decSingleToPacked #define decFloatToEngString decSingleToEngString
#define decFloatToString decSingleToString #define decFloatToPacked decSingleToPacked
#define decFloatToWider decSingleToWider #define decFloatToString decSingleToString
#define decFloatZero decSingleZero #define decFloatToWider decSingleToWider
#define decFloatZero decSingleZero
/* Non-computational */ /* Non-computational */
#define decFloatRadix decSingleRadix #define decFloatRadix decSingleRadix
#define decFloatVersion decSingleVersion #define decFloatVersion decSingleVersion
#include "decNumberLocal.h" /* local includes (need DECPMAX) */ #include "decNumberLocal.h" /* local includes (need DECPMAX) */
#include "decCommon.c" /* non-basic decFloat routines */ #include "decCommon.c" /* non-basic decFloat routines */
......
...@@ -31,24 +31,22 @@ ...@@ -31,24 +31,22 @@
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* decSingle.h -- Decimal 32-bit format module header */ /* decSingle.h -- Decimal 32-bit format module header */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* Please see decFloats.h for an overview and documentation details. */
/* ------------------------------------------------------------------ */
#if !defined(DECSINGLE) #if !defined(DECSINGLE)
#define DECSINGLE #define DECSINGLE
#define DECSINGLENAME "decSingle" /* Short name */ #define DECSINGLENAME "decSingle" /* Short name */
#define DECSINGLETITLE "Decimal 32-bit datum" /* Verbose name */ #define DECSINGLETITLE "Decimal 32-bit datum" /* Verbose name */
#define DECSINGLEAUTHOR "Mike Cowlishaw" /* Who to blame */ #define DECSINGLEAUTHOR "Mike Cowlishaw" /* Who to blame */
/* parameters for decSingles */ /* parameters for decSingles */
#define DECSINGLE_Bytes 4 /* length */ #define DECSINGLE_Bytes 4 /* length */
#define DECSINGLE_Pmax 7 /* maximum precision (digits) */ #define DECSINGLE_Pmax 7 /* maximum precision (digits) */
#define DECSINGLE_Emin -95 /* minimum adjusted exponent */ #define DECSINGLE_Emin -95 /* minimum adjusted exponent */
#define DECSINGLE_Emax 96 /* maximum adjusted exponent */ #define DECSINGLE_Emax 96 /* maximum adjusted exponent */
#define DECSINGLE_EmaxD 3 /* maximum exponent digits */ #define DECSINGLE_EmaxD 3 /* maximum exponent digits */
#define DECSINGLE_Bias 101 /* bias for the exponent */ #define DECSINGLE_Bias 101 /* bias for the exponent */
#define DECSINGLE_String 16 /* maximum string length, +1 */ #define DECSINGLE_String 16 /* maximum string length, +1 */
#define DECSINGLE_EconL 6 /* exponent continuation length */ #define DECSINGLE_EconL 6 /* exponent continuation length */
#define DECSINGLE_Declets 2 /* count of declets */ #define DECSINGLE_Declets 2 /* count of declets */
/* highest biased exponent (Elimit-1) */ /* highest biased exponent (Elimit-1) */
...@@ -59,11 +57,11 @@ ...@@ -59,11 +57,11 @@
#include "decQuad.h" #include "decQuad.h"
#include "decDouble.h" #include "decDouble.h"
/* The decSingle decimal 32-bit type, accessible by various types */ /* The decSingle decimal 32-bit type, accessible by all sizes */
typedef union { typedef union {
uint8_t bytes[DECSINGLE_Bytes]; /* fields: 1, 5, 6, 20 bits */ uint8_t bytes[DECSINGLE_Bytes]; /* fields: 1, 5, 6, 20 bits */
uint16_t shorts[DECSINGLE_Bytes/2]; uint16_t shorts[DECSINGLE_Bytes/2];
uint32_t words[DECSINGLE_Bytes/4]; uint32_t words[DECSINGLE_Bytes/4];
} decSingle; } decSingle;
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
...@@ -75,6 +73,7 @@ ...@@ -75,6 +73,7 @@
/* Utilities (binary argument(s) or result, extractors, etc.) */ /* Utilities (binary argument(s) or result, extractors, etc.) */
extern decSingle * decSingleFromBCD(decSingle *, int32_t, const uint8_t *, int32_t); extern decSingle * decSingleFromBCD(decSingle *, int32_t, const uint8_t *, int32_t);
extern decSingle * decSingleFromPacked(decSingle *, int32_t, const uint8_t *); extern decSingle * decSingleFromPacked(decSingle *, int32_t, const uint8_t *);
extern decSingle * decSingleFromPackedChecked(decSingle *, int32_t, const uint8_t *);
extern decSingle * decSingleFromString(decSingle *, const char *, decContext *); extern decSingle * decSingleFromString(decSingle *, const char *, decContext *);
extern decSingle * decSingleFromWider(decSingle *, const decDouble *, decContext *); extern decSingle * decSingleFromWider(decSingle *, const decDouble *, decContext *);
extern int32_t decSingleGetCoefficient(const decSingle *, uint8_t *); extern int32_t decSingleGetCoefficient(const decSingle *, uint8_t *);
...@@ -97,7 +96,8 @@ ...@@ -97,7 +96,8 @@
/* decNumber conversions; these are implemented as macros so as not */ /* decNumber conversions; these are implemented as macros so as not */
/* to force a dependency on decimal32 and decNumber in decSingle. */ /* to force a dependency on decimal32 and decNumber in decSingle. */
/* decSingleFromNumber returns a decimal32 * to avoid warnings. */
#define decSingleToNumber(dq, dn) decimal32ToNumber((decimal32 *)(dq), dn) #define decSingleToNumber(dq, dn) decimal32ToNumber((decimal32 *)(dq), dn)
#define decSingleFromNumber(dq, dn, set) (decSingle *)decimal32FromNumber((decimal32 *)(dq), dn, set) #define decSingleFromNumber(dq, dn, set) decimal32FromNumber((decimal32 *)(dq), dn, set)
#endif #endif
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
02110-1301, USA. */ 02110-1301, USA. */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* Decimal 128-bit format module header */ /* Decimal 128-bit format module header */
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
#if !defined(DECIMAL128) #if !defined(DECIMAL128)
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#define DECIMAL128_Bias 6176 /* bias for the exponent */ #define DECIMAL128_Bias 6176 /* bias for the exponent */
#define DECIMAL128_String 43 /* maximum string length, +1 */ #define DECIMAL128_String 43 /* maximum string length, +1 */
#define DECIMAL128_EconL 12 /* exp. continuation length */ #define DECIMAL128_EconL 12 /* exp. continuation length */
/* highest biased exponent (Elimit-1) */ /* highest biased exponent (Elimit-1) */
#define DECIMAL128_Ehigh (DECIMAL128_Emax+DECIMAL128_Bias-DECIMAL128_Pmax+1) #define DECIMAL128_Ehigh (DECIMAL128_Emax+DECIMAL128_Bias-DECIMAL128_Pmax+1)
/* check enough digits, if pre-defined */ /* check enough digits, if pre-defined */
...@@ -71,20 +71,20 @@ ...@@ -71,20 +71,20 @@
/* special values [top byte excluding sign bit; last two bits are */ /* special values [top byte excluding sign bit; last two bits are */
/* don't-care for Infinity on input, last bit don't-care for NaN] */ /* don't-care for Infinity on input, last bit don't-care for NaN] */
#if !defined(DECIMAL_NaN) #if !defined(DECIMAL_NaN)
#define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
#define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */ #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
#define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
#endif #endif
#include "decimal128Local.h" #include "decimal128Local.h"
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
/* Routines */ /* Routines */
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
#include "decimal128Symbols.h" #include "decimal128Symbols.h"
/* String conversions */ /* String conversions */
decimal128 * decimal128FromString(decimal128 *, const char *, decContext *); decimal128 * decimal128FromString(decimal128 *, const char *, decContext *);
char * decimal128ToString(const decimal128 *, char *); char * decimal128ToString(const decimal128 *, char *);
char * decimal128ToEngString(const decimal128 *, char *); char * decimal128ToEngString(const decimal128 *, char *);
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
decContext *); decContext *);
decNumber * decimal128ToNumber(const decimal128 *, decNumber *); decNumber * decimal128ToNumber(const decimal128 *, decNumber *);
/* Format-dependent utilities */ /* Format-dependent utilities */
uint32_t decimal128IsCanonical(const decimal128 *); uint32_t decimal128IsCanonical(const decimal128 *);
decimal128 * decimal128Canonical(decimal128 *, const decimal128 *); decimal128 * decimal128Canonical(decimal128 *, const decimal128 *);
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#if !defined(DECIMAL32) #if !defined(DECIMAL32)
#define DECIMAL32 #define DECIMAL32
#define DEC32NAME "decimal32" /* Short name */ #define DEC32NAME "decimal32" /* Short name */
#define DEC32FULLNAME "Decimal 32-bit Number" /* Verbose name */ #define DEC32FULLNAME "Decimal 32-bit Number" /* Verbose name */
#define DEC32AUTHOR "Mike Cowlishaw" /* Who to blame */ #define DEC32AUTHOR "Mike Cowlishaw" /* Who to blame */
/* parameters for decimal32s */ /* parameters for decimal32s */
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#define DECIMAL32_Bias 101 /* bias for the exponent */ #define DECIMAL32_Bias 101 /* bias for the exponent */
#define DECIMAL32_String 15 /* maximum string length, +1 */ #define DECIMAL32_String 15 /* maximum string length, +1 */
#define DECIMAL32_EconL 6 /* exp. continuation length */ #define DECIMAL32_EconL 6 /* exp. continuation length */
/* highest biased exponent (Elimit-1) */ /* highest biased exponent (Elimit-1) */
#define DECIMAL32_Ehigh (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1) #define DECIMAL32_Ehigh (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1)
/* check enough digits, if pre-defined */ /* check enough digits, if pre-defined */
...@@ -71,18 +71,18 @@ ...@@ -71,18 +71,18 @@
/* special values [top byte excluding sign bit; last two bits are */ /* special values [top byte excluding sign bit; last two bits are */
/* don't-care for Infinity on input, last bit don't-care for NaN] */ /* don't-care for Infinity on input, last bit don't-care for NaN] */
#if !defined(DECIMAL_NaN) #if !defined(DECIMAL_NaN)
#define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
#define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */ #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
#define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
#endif #endif
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
/* Routines */ /* Routines */
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
#include "decimal32Symbols.h" #include "decimal32Symbols.h"
/* String conversions */ /* String conversions */
decimal32 * decimal32FromString(decimal32 *, const char *, decContext *); decimal32 * decimal32FromString(decimal32 *, const char *, decContext *);
char * decimal32ToString(const decimal32 *, char *); char * decimal32ToString(const decimal32 *, char *);
char * decimal32ToEngString(const decimal32 *, char *); char * decimal32ToEngString(const decimal32 *, char *);
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
decContext *); decContext *);
decNumber * decimal32ToNumber(const decimal32 *, decNumber *); decNumber * decimal32ToNumber(const decimal32 *, decNumber *);
/* Format-dependent utilities */ /* Format-dependent utilities */
uint32_t decimal32IsCanonical(const decimal32 *); uint32_t decimal32IsCanonical(const decimal32 *);
decimal32 * decimal32Canonical(decimal32 *, const decimal32 *); decimal32 * decimal32Canonical(decimal32 *, const decimal32 *);
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#if !defined(DECIMAL64) #if !defined(DECIMAL64)
#define DECIMAL64 #define DECIMAL64
#define DEC64NAME "decimal64" /* Short name */ #define DEC64NAME "decimal64" /* Short name */
#define DEC64FULLNAME "Decimal 64-bit Number" /* Verbose name */ #define DEC64FULLNAME "Decimal 64-bit Number" /* Verbose name */
#define DEC64AUTHOR "Mike Cowlishaw" /* Who to blame */ #define DEC64AUTHOR "Mike Cowlishaw" /* Who to blame */
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#define DECIMAL64_Bias 398 /* bias for the exponent */ #define DECIMAL64_Bias 398 /* bias for the exponent */
#define DECIMAL64_String 24 /* maximum string length, +1 */ #define DECIMAL64_String 24 /* maximum string length, +1 */
#define DECIMAL64_EconL 8 /* exp. continuation length */ #define DECIMAL64_EconL 8 /* exp. continuation length */
/* highest biased exponent (Elimit-1) */ /* highest biased exponent (Elimit-1) */
#define DECIMAL64_Ehigh (DECIMAL64_Emax+DECIMAL64_Bias-DECIMAL64_Pmax+1) #define DECIMAL64_Ehigh (DECIMAL64_Emax+DECIMAL64_Bias-DECIMAL64_Pmax+1)
/* check enough digits, if pre-defined */ /* check enough digits, if pre-defined */
...@@ -73,18 +73,18 @@ ...@@ -73,18 +73,18 @@
/* special values [top byte excluding sign bit; last two bits are */ /* special values [top byte excluding sign bit; last two bits are */
/* don't-care for Infinity on input, last bit don't-care for NaN] */ /* don't-care for Infinity on input, last bit don't-care for NaN] */
#if !defined(DECIMAL_NaN) #if !defined(DECIMAL_NaN)
#define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
#define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */ #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
#define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
#endif #endif
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
/* Routines */ /* Routines */
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
#include "decimal64Symbols.h" #include "decimal64Symbols.h"
/* String conversions */ /* String conversions */
decimal64 * decimal64FromString(decimal64 *, const char *, decContext *); decimal64 * decimal64FromString(decimal64 *, const char *, decContext *);
char * decimal64ToString(const decimal64 *, char *); char * decimal64ToString(const decimal64 *, char *);
char * decimal64ToEngString(const decimal64 *, char *); char * decimal64ToEngString(const decimal64 *, char *);
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
decContext *); decContext *);
decNumber * decimal64ToNumber(const decimal64 *, decNumber *); decNumber * decimal64ToNumber(const decimal64 *, decNumber *);
/* Format-dependent utilities */ /* Format-dependent utilities */
uint32_t decimal64IsCanonical(const decimal64 *); uint32_t decimal64IsCanonical(const decimal64 *);
decimal64 * decimal64Canonical(decimal64 *, const decimal64 *); decimal64 * decimal64Canonical(decimal64 *, const decimal64 *);
......
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