Method: BigDecimal#inspect

Defined in:
ext/bigdecimal/bigdecimal.c

#inspectObject

Returns a string representation of self.

BigDecimal("1234.5678").inspect
  #=> "0.12345678e4"


2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
# File 'ext/bigdecimal/bigdecimal.c', line 2431

static VALUE
BigDecimal_inspect(VALUE self)
{
    BDVALUE v;
    volatile VALUE str;
    size_t nc;

    v = GetBDValueMust(self);
    nc = VpNumOfChars(v.real, "E");

    str = rb_str_new(0, nc);
    VpToString(v.real, RSTRING_PTR(str), RSTRING_LEN(str), 0, 0);
    rb_str_resize(str, strlen(RSTRING_PTR(str)));

    RB_GC_GUARD(v.bigdecimal);
    return str;
}