Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
BigDecimal.limit
BigDecimal.limit(digits)
Limit the number of significant digits in newly created BigDecimal
numbers to the specified value. Rounding is performed as necessary,
as specified by BigDecimal.mode.
A limit of 0, the default, means no upper limit.
The limit specified by this method takes less priority over any limit
specified to instance methods such as ceil, floor, truncate, or round.
ext/bigdecimal/bigdecimal.c
View on GitHub ↗
static VALUE
BigDecimal_limit(int argc, VALUE *argv, VALUE self)
{
VALUE nFig;
VALUE nCur = SIZET2NUM(VpGetPrecLimit());
if (rb_scan_args(argc, argv, "01", &nFig) == 1) {
int nf;
if (NIL_P(nFig)) return nCur;
nf = NUM2INT(nFig);
if (nf < 0) {
rb_raise(rb_eArgError, "argument must be positive");
}
VpSetPrecLimit(nf);
}
return nCur;
}
No documentation available