End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
BigDecimal#mult
mult(value, digits)
ext/bigdecimal/bigdecimal.c
View on GitHub ↗
static VALUE
BigDecimal_mult2(VALUE self, VALUE b, VALUE n)
{
ENTER(2);
Real *cv;
SIGNED_VALUE mx = GetPrecisionInt(n);
if (mx == 0) return BigDecimal_mult(self, b);
else {
size_t pl = VpSetPrecLimit(0);
VALUE c = BigDecimal_mult(self, b);
VpSetPrecLimit(pl);
GUARD_OBJ(cv, GetVpValue(c, 1));
VpLeftRound(cv, VpGetRoundMode(), mx);
return ToValue(cv);
}
}
Multiply by the specified value.
e.g.
Example
c = a.mult(b,n) c = a * b
- digits
-
If specified and less than the number of significant digits of the result, the result is rounded to that number of digits, according to
BigDecimal.mode.