From b520fb5479574aab38f116728e1b06a37cacba4d Mon Sep 17 00:00:00 2001 From: dexX7 Date: Wed, 6 May 2015 15:31:21 +0200 Subject: [PATCH] ceil in xToInt64, when rounding up --- src/mastercore_mdex.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mastercore_mdex.cpp b/src/mastercore_mdex.cpp index 523ed44f47487..b71fd050afec3 100644 --- a/src/mastercore_mdex.cpp +++ b/src/mastercore_mdex.cpp @@ -75,11 +75,17 @@ static inline std::string xToString(XDOUBLE value) static inline int64_t xToInt64(XDOUBLE value, bool fRoundUp = true) { - if (fRoundUp) value += (XDOUBLE) 0.5; // ROUND UP std::string str_value = value.str(INTERNAL_PRECISION_LEN, std::ios_base::fixed); std::string str_value_int_part = str_value.substr(0, str_value.find_first_of(".")); + int64_t value_int = boost::lexical_cast(str_value_int_part); - return boost::lexical_cast(str_value_int_part); + if (fRoundUp) { // < temporary, all this to be replaced by boost::rational + if (value - value_int > 0) { + value_int++; + } + } + + return value_int; } static void PriceCheck(const std::string& label, XDOUBLE left, XDOUBLE right)