Skip to content

Commit

Permalink
ceil in xToInt64, when rounding up
Browse files Browse the repository at this point in the history
  • Loading branch information
dexX7 committed May 7, 2015
1 parent 27fb7be commit b520fb5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/mastercore_mdex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t>(str_value_int_part);

return boost::lexical_cast<int64_t>(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)
Expand Down

0 comments on commit b520fb5

Please sign in to comment.