|
|
@@ -167,6 +167,13 @@ bigdecimal & math::operator*=(bigdecimal & rhs, bigdecimal const & lhs) {
|
|
|
rhs.is_negative = is_neg;
|
|
|
} else {
|
|
|
detail::multiply(rhs.data, lhs.data, offset);
|
|
|
+ int32_t const steps = add_scale(rhs.scale_), nsteps = add_scale(new_scale);
|
|
|
+ int32_t const off1 = (steps <= 0 ? 0 : 1), off2 = (steps < 0 ? 0 : 1);
|
|
|
+ if (steps - off1 > nsteps) {
|
|
|
+ rhs.data.erase(rhs.data.begin(), rhs.data.begin() + steps - nsteps - off1);
|
|
|
+ } else if (steps + off2 < nsteps) {
|
|
|
+ rhs.data.insert(rhs.data.begin(), size_t(nsteps-steps-off2), 0);
|
|
|
+ }
|
|
|
rhs.scale_ = new_scale; // TODO: more steps in certain cases
|
|
|
return rhs;
|
|
|
}
|