本文整理汇总了C++中ObNumber::right_shift方法的典型用法代码示例。如果您正苦于以下问题:C++ ObNumber::right_shift方法的具体用法?C++ ObNumber::right_shift怎么用?C++ ObNumber::right_shift使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObNumber
的用法示例。
在下文中一共展示了ObNumber::right_shift方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: round_to
int ObNumber::round_to(int8_t precision, int8_t scale, int8_t &nwords, int8_t &vscale, uint32_t *words) const
{
OB_ASSERT(precision >= scale && 0 <= scale && NULL != words);
int ret = OB_SUCCESS;
ObNumber clone = *this;
bool is_neg = is_negative();
if (is_neg)
{
negate(clone, clone);
}
if (clone.vscale_ > scale)
{
clone.right_shift(static_cast<int8_t> (clone.vscale_ - scale));
clone.remove_leading_zeroes();
}
ObNumber clone_clone = clone;
int8_t vprec = 0;
ObNumber remainder;
while (!clone_clone.is_zero())
{
div_uint32(clone_clone, 10, clone_clone, remainder);
clone_clone.remove_leading_zeroes();
++vprec;
}
if (vprec > precision)
{
ret = JD_VALUE_OUT_OF_RANGE;
jlog(WARNING, "value is not representable with the precision and scale, p=%hhd s=%hhd vp=%hhd vs=%hhd",
precision, scale, vprec, this->vscale_);
}
else
{
if (is_neg)
{
negate(clone, clone);
}
nwords = clone.nwords_;
vscale = clone.vscale_;
for (int8_t i = 0; i < clone.nwords_; ++i)
{
words[i] = clone.words_[i];
}
}
return ret;
}
示例2: round_fraction_part
void ObNumber::round_fraction_part(int8_t scale)
{
ObNumber *clone = this;
ObNumber neg_this;
bool is_neg = is_negative();
if (is_neg)
{
negate(*this, neg_this);
clone = &neg_this;
}
if (vscale_ > scale)
{
clone->right_shift(static_cast<int8_t> (vscale_ - scale));
}
if (is_neg)
{
negate(*clone, *this);
}
remove_leading_zeroes();
}