#include <math.h>
/* needed for building microsoft dll */
+#ifdef __GNUC__
#define DECINLINE __inline
+#else
+#define DECINLINE
+#endif
#define LIT_GUINT32(x) x
#define LIT_GUINT64(x) x##L
#define DECIMAL_LOG_NEGINF -1000
-static guint32 constantsDecadeInt32Factors[DECIMAL_MAX_INTFACTORS+1] = {
+static const guint32 constantsDecadeInt32Factors[DECIMAL_MAX_INTFACTORS+1] = {
LIT_GUINT32(1), LIT_GUINT32(10), LIT_GUINT32(100), LIT_GUINT32(1000),
LIT_GUINT32(10000), LIT_GUINT32(100000), LIT_GUINT32(1000000),
LIT_GUINT32(10000000), LIT_GUINT32(100000000), LIT_GUINT32(1000000000)
guint64 hi;
} dec128_repr;
-static dec128_repr dec128decadeFactors[DECIMAL_MAX_SCALE+1] = {
+static const dec128_repr dec128decadeFactors[DECIMAL_MAX_SCALE+1] = {
LIT_DEC128( 0, 0, 1u), /* == 1 */
LIT_DEC128( 0, 0, 10u), /* == 10 */
LIT_DEC128( 0, 0, 100u), /* == 100 */
if (pRest) *pRest = (guint32) a;
a <<= 1;
- return (a > factor || (a == factor && (c & 1) == 1)) ? 1 : 0;
+ return (a >= factor || (a == factor && (c & 1) == 1)) ? 1 : 0;
}
/* division: x(192bit) /= factor(32bit)
ahi += 0x400;
if ((ahi & LIT_GUINT64_HIGHBIT) == 0) { /* overflow ? */
ahi >>= 1;
- texp++;
+ texp--;
} else if ((roundBits & 0x400) == 0) ahi &= ~1;
/* 96 bit => 1 implizit bit and 52 explicit bits */