From 8e7137f3bb5600c9826265070414f624cc0b5cac Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Fri, 13 Oct 2017 12:53:15 +0200 Subject: [PATCH] Fixed saving of QDecDouble numbers. --- core/define.h | 4 ++-- qdecimal/src/QDecDouble.hh | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/define.h b/core/define.h index 6ca3f2d..a77c332 100644 --- a/core/define.h +++ b/core/define.h @@ -10,8 +10,8 @@ #define PERM_DELETE "DELETE" #define DEC_MULTIPLE 100 -#define TO_DEC(num) QDecDouble((double)num / DEC_MULTIPLE) -#define FROM_DEC(num) num.toDouble() * DEC_MULTIPLE +#define TO_DEC(num) (QDecDouble(num) / QDecDouble(DEC_MULTIPLE)) +#define FROM_DEC(num) (num * QDecDouble(DEC_MULTIPLE)).toInt32() #ifndef PLUGIN_ROOT #ifdef _WIN32 diff --git a/qdecimal/src/QDecDouble.hh b/qdecimal/src/QDecDouble.hh index e3eeda2..139abf1 100644 --- a/qdecimal/src/QDecDouble.hh +++ b/qdecimal/src/QDecDouble.hh @@ -153,6 +153,10 @@ class QDECIMAL_EXPORT QDecDouble } double toDouble() const; + + int32_t toInt32(QDecContext* c = 0) const { + return decDoubleToInt32(&m_data, CXT(c), DEC_ROUND_HALF_UP); + } QByteArray toEngString() const { char str[MaxStrSize] = { 0 };