Method: BigDecimal#precs

Defined in:
bigdecimal.c

#precsArray

Returns an Array of two Integer values that represent platform-dependent internal storage properties.

This method is deprecated and will be removed in the future. Instead, use BigDecimal#n_significant_digits for obtaining the number of significant digits in scientific notation, and BigDecimal#precision for obtaining the number of digits in decimal notation.

BigDecimal('5').precs #=> [9, 18]

Returns:

  • (Array)


369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'bigdecimal.c', line 369

static VALUE
BigDecimal_prec(VALUE self)
{
    ENTER(1);
    Real *p;
    VALUE obj;

    rb_category_warn(RB_WARN_CATEGORY_DEPRECATED,
                     "BigDecimal#precs is deprecated and will be removed in the future; "
                     "use BigDecimal#precision instead.");

    GUARD_OBJ(p, GetVpValue(self, 1));
    obj = rb_assoc_new(SIZET2NUM(p->Prec*VpBaseFig()),
		       SIZET2NUM(p->MaxPrec*VpBaseFig()));
    return obj;
}