void Decimal::co_normalize(Decimal& x, Decimal& y) { if (x.m_places == y.m_places) { // do nothing } else if (x.m_places < y.m_places) { if (x.rescale(y.m_places) != 0) { JEWEL_THROW ( DecimalRangeException, "Unsafe attempt to set fractional precision in course " "of co-normalization attempt." ); } } else { JEWEL_ASSERT (y.m_places < x.m_places); if (y.rescale(x.m_places) != 0) { JEWEL_THROW ( DecimalRangeException, "Unsafe attempt to set fractional precision in course " "of co-normalization attempt." ); } } return; }
Decimal round(Decimal const& x, Decimal::places_type decimal_places) { Decimal ret = x; if (ret.rescale(decimal_places) != 0) { JEWEL_THROW ( DecimalRangeException, "Decimal number cannot safely be rounded to " "this number of places." ); } return ret; }